]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
firmware: dmi-sysfs: Fix memory leak in dmi_sysfs_register_handle
authorMiaoqian Lin <linmq006@gmail.com>
Wed, 11 May 2022 07:14:19 +0000 (11:14 +0400)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 14 Jun 2022 14:59:33 +0000 (16:59 +0200)
commitc66cc3c62870a27ea8f060a7e4c1ad8d26dd3f0d
tree09eeea5b84a59df10bf8dd3c5607750133904a12
parenta1c987d451e9a3c35f3fc92537a0004afa57fdac
firmware: dmi-sysfs: Fix memory leak in dmi_sysfs_register_handle

[ Upstream commit 660ba678f9998aca6db74f2dd912fa5124f0fa31 ]

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 this issue by calling kobject_put().

Fixes: 948af1f0bbc8 ("firmware: Basic dmi-sysfs support")
Signed-off-by: Miaoqian Lin <linmq006@gmail.com>
Link: https://lore.kernel.org/r/20220511071421.9769-1-linmq006@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/firmware/dmi-sysfs.c