android_kernel_xiaomi_sm8350/drivers/base
Jesper Juhl d478376cb0 driver core: fix small mem leak in driver_add_kobj()
The Coverity checker spotted that we leak the storage allocated to 'name' in
int driver_add_kobj().  The leak looks legit to me - this is the code :

int driver_add_kobj(struct device_driver *drv, struct kobject *kobj,
                    const char *fmt, ...)
{
        va_list args;
        char *name;
        int ret;

        va_start(args, fmt);
        name = kvasprintf(GFP_KERNEL, fmt, args);
        ^^^^^^^^ This dynamically allocates space...

        va_end(args);

        if (!name)
                return -ENOMEM;

        return kobject_add(kobj, &drv->p->kobj, "%s", name);
	^^^^^^^^ This neglects to free the space allocated
}

Inside kobject_add() a copy of 'name' will be made and used.  As far as I can
see, Coverity is correct in flagging this as a leak, but I'd like some
configmation before the patch is applied.

This should fix it.

Signed-off-by: Jesper Juhl <jesper.juhl@gmail.com>
Cc: Greg KH <greg@kroah.com>
Cc: Kay Sievers <kay.sievers@vrfy.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2008-03-28 14:45:23 -07:00
..
power PM: fix new mutex-locking bug in the PM core 2008-03-04 14:47:05 -08:00
attribute_container.c
base.h
bus.c Driver core: Fix error handling in bus_add_driver(). 2008-02-21 15:27:07 -08:00
class.c
core.c driver core: debug for bad dev_attr_show() return value. 2008-03-24 22:33:49 -07:00
cpu.c register_cpu __devinit or __cpuinit 2008-02-06 10:41:01 -08:00
dd.c
devres.c
dma-mapping.c
driver.c driver core: fix small mem leak in driver_add_kobj() 2008-03-28 14:45:23 -07:00
firmware_class.c Driver core: Revert "Fix Firmware class name collision" 2008-02-07 11:31:46 -08:00
firmware.c
hypervisor.c
init.c
isa.c
Kconfig
Makefile
map.c
memory.c
module.c
node.c
platform.c drivers: fix dma_get_required_mask 2008-03-10 16:33:33 -07:00
sys.c sysdev: fix problem with sysdev_class being re-registered 2008-03-10 16:33:32 -07:00
topology.c
transport_class.c docbook: fix kernel-api source files 2008-03-03 10:47:14 -08:00