summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLevente Kurusa <levex@linux.com>2015-09-14 20:56:12 +0300
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2015-10-05 06:47:09 +0300
commit5052436dcb7eac532cf2ffd6650be01d3f15e0b5 (patch)
tree87ac7ae4040bf709aa7cd1f1d67b078293304e21
parent7c22e645cd742b82ec232e4f2328fc53d247ccea (diff)
downloadlinux-5052436dcb7eac532cf2ffd6650be01d3f15e0b5.tar.xz
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: Levente Kurusa <levex@linux.com> Acked-by: Evgeniy Polyakov <zbr@ioremap.net> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r--drivers/w1/w1_int.c3
1 files changed, 1 insertions, 2 deletions
diff --git a/drivers/w1/w1_int.c b/drivers/w1/w1_int.c
index 47249a30eae3..20f766afa4c7 100644
--- a/drivers/w1/w1_int.c
+++ b/drivers/w1/w1_int.c
@@ -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));
- kfree(dev);
+ put_device(&dev->dev);
dev = NULL;
}