]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
base: soc: use put_device() instead of kfree()
authorArvind Yadav <arvind.yadav.cs@gmail.com>
Sun, 11 Mar 2018 05:55:48 +0000 (11:25 +0530)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 15 Mar 2018 13:37:03 +0000 (14:37 +0100)
Never directly free @dev after calling device_register(), even
if it returned an error! Always use put_device() to give up the
reference initialized.

Signed-off-by: Arvind Yadav <arvind.yadav.cs@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/base/soc.c

index 4e80f48ad5d6ce41dc41e83b4e6c2075dbd9d0d5..10b280f30217bcc6ec72cea2d7ca9612fc299293 100644 (file)
@@ -150,6 +150,8 @@ struct soc_device *soc_device_register(struct soc_device_attribute *soc_dev_attr
 
 out3:
        ida_simple_remove(&soc_ida, soc_dev->soc_dev_num);
+       put_device(&soc_dev->dev);
+       soc_dev = NULL;
 out2:
        kfree(soc_dev);
 out1: