Commit 5052436d authored by Levente Kurusa's avatar Levente Kurusa Committed by Greg Kroah-Hartman

drivers/w1/w1_int.c: call put_device if device_register fails

Currently, memsetting and kfreeing the device is bad behaviour.  The
device will have a reference count of 1 and hence can cause trouble
because it has kfree'd.  Proper way to handle a failed device_register is
to call put_device right after it fails.
Signed-off-by: default avatarLevente Kurusa <>
Acked-by: default avatarEvgeniy Polyakov <>
Signed-off-by: default avatarAndrew Morton <>
Signed-off-by: default avatarGreg Kroah-Hartman <>
parent 7c22e645
......@@ -91,8 +91,7 @@ static struct w1_master *w1_alloc_dev(u32 id, int slave_count, int slave_ttl,
err = device_register(&dev->dev);
if (err) {
pr_err("Failed to register master device. err=%d\n", err);
memset(dev, 0, sizeof(struct w1_master));
dev = NULL;
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment