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
..
2008-03-17 07:56:31 -04:00
2008-02-05 09:44:23 -08:00
2008-03-23 20:28:20 +01:00
2008-03-28 14:45:22 -07:00
2008-02-08 09:22:38 -08:00
2008-03-15 19:17:12 -07:00
2008-02-13 16:21:19 -08:00
2008-03-03 10:47:13 -08:00
2008-03-19 18:53:37 -07:00
2008-02-26 14:12:09 +09:00
2008-03-18 01:22:10 -04:00
2008-03-24 22:26:15 -07:00
2008-03-04 16:35:12 -08:00