is there a memleak in function acpi_cppc_processor_probe

[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 acpi_cppc_processor_probe() in drivers/acpi/cppc_acpi.c may
have the similar issue and leak kobject.
if kobject_init_and_add() failed, the cpc_ptr->kobj may already
increased it's refcnt and allocated memory to store it's name,
so a kobject_put is need before return.

int acpi_cppc_processor_probe(struct acpi_processor *pr)
{

ret = kobject_init_and_add(&cpc_ptr->kobj, &cppc_ktype, &cpu_dev->kobj,
"acpi_cppc");
if (ret) {
per_cpu(cpc_desc_ptr, pr->id) = NULL;
goto out_free;
}

kfree(output.pointer);
return 0;

out_free:
/* Free all the mapped sys mem areas for this CPU */
for (i = 2; i < cpc_ptr->num_entries; i++) {
void __iomem *addr = cpc_ptr->cpc_regs[i-2].sys_mem_vaddr;

if (addr)
iounmap(addr);
}
kfree(cpc_ptr);

out_buf_free:
kfree(output.pointer);
return ret;
}


Best regards,
Lin Yi



[Index of Archives]     [Linux IBM ACPI]     [Linux Power Management]     [Linux Kernel]     [Linux Laptop]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Video 4 Linux]     [Device Mapper]     [Linux Resources]

  Powered by Linux