Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit e6fed609 authored by Miaoqian Lin's avatar Miaoqian Lin Committed by Greg Kroah-Hartman
Browse files

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: 73f368cf ("Kobject: change drivers/parisc/pdc_stable.c to use kobject_init_and_add")
Signed-off-by: default avatarMiaoqian Lin <linmq006@gmail.com>
Signed-off-by: default avatarHelge Deller <deller@gmx.de>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 0e0de4a3
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -992,8 +992,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);