* [BUG]is there a memleak in function efivar_create_sysfs_entry?
@ 2020-05-06 13:28 亿一
0 siblings, 0 replies; only message in thread
From: 亿一 @ 2020-05-06 13:28 UTC (permalink / raw)
To: ardb; +Cc: linux-efi
Hi all,
I notice that most of the usage of kobject_init_and_add in drivers are
wrong, and now some drivers code has maken it right,
please see commit dfb5394f804e (https://lkml.org/lkml/2020/4/11/282).
function efivar_create_sysfs_entry() in drivers/firmware/efi/efivars.c may
have the similar issue and leak kobject.
if kobject_init_and_add() failed, the new_var->kobj may already
increased it's refcnt and allocated memory to store it's name,
so a kobject_put is need before return.
static int
efivar_create_sysfs_entry(struct efivar_entry *new_var)
{
ret = kobject_init_and_add(&new_var->kobj, &efivar_ktype,
NULL, "%s", short_name);
kfree(short_name);
if (ret)
return ret;
kobject_uevent(&new_var->kobj, KOBJ_ADD);
if (efivar_entry_add(new_var, &efivar_sysfs_list)) {
efivar_unregister(new_var);
return -EINTR;
}
return 0;
}
Best regards,
Lin Yi
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2020-05-06 13:29 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-06 13:28 [BUG]is there a memleak in function efivar_create_sysfs_entry? 亿一
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).