summaryrefslogtreecommitdiff
path: root/drivers/parisc
diff options
context:
space:
mode:
authorMiaoqian Lin <linmq006@gmail.com>2022-01-20 12:18:12 +0000
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2022-01-27 10:54:31 +0100
commite1840365ed4f831f51dfd7b3af5e39045f3d62b7 (patch)
tree94a7aaf0615ded886260ffe294fbb2aa7de4141e /drivers/parisc
parentd806eb5f4e231c7c470b7e9d13277d9e69c80a67 (diff)
parisc: pdc_stable: Fix memory leak in pdcs_register_pathentries
commit d24846a4246b6e61ecbd036880a4adf61681d241 upstream. kobject_init_and_add() takes reference even when it fails. According to the doc of kobject_init_and_add(): If this function returns an error, kobject_put() must be called to properly clean up the memory associated with the object. Fix memory leak by calling kobject_put(). Fixes: 73f368cf679b ("Kobject: change drivers/parisc/pdc_stable.c to use kobject_init_and_add") Signed-off-by: Miaoqian Lin <linmq006@gmail.com> Signed-off-by: Helge Deller <deller@gmx.de> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/parisc')
-rw-r--r--drivers/parisc/pdc_stable.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/drivers/parisc/pdc_stable.c b/drivers/parisc/pdc_stable.c
index e090978518f1..4760f82def6e 100644
--- a/drivers/parisc/pdc_stable.c
+++ b/drivers/parisc/pdc_stable.c
@@ -979,8 +979,10 @@ pdcs_register_pathentries(void)
entry->kobj.kset = paths_kset;
err = kobject_init_and_add(&entry->kobj, &ktype_pdcspath, NULL,
"%s", entry->name);
- if (err)
+ if (err) {
+ kobject_put(&entry->kobj);
return err;
+ }
/* kobject is now registered */
write_lock(&entry->rw_lock);