mirror of
https://github.com/torvalds/linux.git
synced 2026-06-06 21:45:45 +02:00
firmware: dmi-sysfs: Fix memory leak in dmi_sysfs_register_handle
[ Upstream commit660ba678f9] 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:948af1f0bb("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>
This commit is contained in:
parent
94acaaad47
commit
985706bd3b
|
|
@ -603,7 +603,7 @@ static void __init dmi_sysfs_register_handle(const struct dmi_header *dh,
|
||||||
"%d-%d", dh->type, entry->instance);
|
"%d-%d", dh->type, entry->instance);
|
||||||
|
|
||||||
if (*ret) {
|
if (*ret) {
|
||||||
kfree(entry);
|
kobject_put(&entry->kobj);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user