[BUG]is there a memleak in function efivar_create_sysfs_entry?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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



[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]

  Powered by Linux