From: Qiushi Wu <wu000...@umn.edu>

kobject_init_and_add() takes reference even when it fails.
If this function returns an error, kobject_put() must be called to
properly clean up the memory associated with the object.

Fixes: dd002e807486 ("Kobject: change drivers/firmware/edd.c to use 
kobject_init_and_add")
Signed-off-by: Qiushi Wu <wu000...@umn.edu>
---
 drivers/firmware/edd.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/firmware/edd.c b/drivers/firmware/edd.c
index 14d0970a7198..c8bb58824a76 100644
--- a/drivers/firmware/edd.c
+++ b/drivers/firmware/edd.c
@@ -718,6 +718,8 @@ edd_device_register(struct edd_device *edev, int i)
        if (!error) {
                edd_populate_dir(edev);
                kobject_uevent(&edev->kobj, KOBJ_ADD);
+       } else {
+               kobject_put(&edev->kobj);
        }
        return error;
 }
-- 
2.17.1

Reply via email to