parisc: pdc_stable: Fix memory leak in pdcs_register_pathentries
authorMiaoqian Lin <linmq006@gmail.com>
Thu, 20 Jan 2022 12:18:12 +0000 (12:18 +0000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 27 Jan 2022 08:01:00 +0000 (09:01 +0100)
commit95ae2679dd36a48fdd0b938eecea2ec9d67eabbd
tree2aace03f297266b6b10b7d0a9bf5d5c47083f7dc
parent95ce6b99869eae207b4d8e5ebd2997c84381f48f
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>
drivers/parisc/pdc_stable.c