linux/drivers
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
..
acorn/char Fix default compose table initialization 2008-03-03 14:53:16 -08:00
acpi revert "ACPI: drivers/acpi: elide a non-zero test on a result that is never 0" 2008-03-28 10:16:53 -07:00
amba
ata [libata] ahci: SB600 workaround is suspect... play it safe for now 2008-03-24 22:40:40 -04:00
atm fore2000 - fix misannotations 2008-03-17 07:56:31 -04:00
auxdisplay
base driver core: fix small mem leak in driver_add_kobj() 2008-03-28 14:45:23 -07:00
block Merge branch 'for-linus' of git://git.kernel.dk/linux-2.6-block 2008-03-18 07:43:14 -07:00
bluetooth Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-2.6 2008-03-12 13:08:09 -07:00
cdrom make cdrom.c:check_for_audio_disc() static 2008-03-04 11:28:41 +01:00
char drivers/char/drm/ati_pcigart.c: fix printk warning 2008-03-28 14:45:21 -07:00
clocksource
connector connector: convert to single-threaded workqueue 2008-03-23 21:51:12 -07:00
cpufreq [CPUFREQ] fix section mismatch warnings 2008-03-05 14:45:31 -05:00
cpuidle cpuidle: fix 100% C0 statistics regression 2008-03-26 00:58:19 -04:00
crypto [HIFN]: Fix invalid config ifdefs for RNG support 2008-02-15 19:15:05 +08:00
dca DCA: convert struct class_device to struct device. 2008-02-08 15:33:33 -08:00
dio dio: ARRAY_SIZE() cleanup 2008-02-05 09:44:23 -08:00
dma fsldma: Fix the DMA halt when using DMA_INTERRUPT async_tx transfer. 2008-03-18 17:00:59 -07:00
edac drivers/edac/i3000: document type promotion 2008-02-07 08:42:23 -08:00
eisa
firewire firewire: fix panic in handle_at_packet 2008-03-20 18:13:05 +01:00
firmware dmi: prevent linked list corruption 2008-02-23 17:12:15 -08:00
gpio gpio/pca953x bugfix: mark as can_sleep 2008-03-10 18:01:19 -07:00
hid HID: update key codes for Apple aluminium 2008-03-18 11:20:33 +01:00
hwmon ibmpex: report temperatures in mC, not C 2008-03-19 18:53:36 -07:00
i2c i2c: Fix docbook problem 2008-03-23 20:28:20 +01:00
ide Revert "ide-tape: schedule driver for removal after 6 months" 2008-03-22 16:44:27 +01:00
ieee1394 ieee1394: sbp2: fix for SYM13FW500 bridge (Datafab disk) 2008-03-14 00:56:59 +01:00
infiniband RDMA/cxgb3: Program hardware IRD with correct value 2008-03-28 10:45:32 -07:00
input ixp4xx-beeper: add MODULE_ALIAS 2008-03-28 14:45:22 -07:00
isdn Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-2.6 2008-03-12 13:08:09 -07:00
leds PWM LED driver 2008-02-08 09:22:38 -08:00
lguest lguest: comment documentation update. 2008-03-28 11:05:54 +11:00
macintosh [POWERPC] Fix build of modular drivers/macintosh/apm_emu.c 2008-03-13 10:09:27 +11:00
mca
md dm io: write error bits form long not int 2008-03-28 14:45:23 -07:00
media V4L/DVB (7367): bug #10211: Fix depencencies for cx2341x 2008-03-20 12:39:02 -03:00
memstick memstick: suppress uninitialized-var warning 2008-03-28 14:45:23 -07:00
message [SCSI] mpt fusion: Power Management fixes for MPT SAS PCI-E controllers 2008-03-18 15:13:40 -05:00
mfd sm501: add support for the SM502 programmable PLL 2008-03-04 16:35:13 -08:00
misc Merge branches 'release', 'ejd', 'sony' and 'wmi' into release 2008-03-13 01:59:52 -04:00
mmc mmc: use sysfs groups to handle conditional attributes 2008-03-22 17:02:20 -07:00
mtd mtd: maps/physmap: fix oops in suspend/resume/shutdown ops 2008-03-28 14:45:22 -07:00
net Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-2.6 2008-03-26 18:35:50 -07:00
nubus nubus: kill drivers/nubus/nubus_syms.c 2008-02-05 09:44:23 -08:00
of [POWERPC] Create and hook up of_platform_device_shutdown 2008-02-06 16:29:59 +11:00
oprofile d_path: Make get_dcookie() use a struct path argument 2008-02-14 21:17:08 -08:00
parisc [PARISC] make ptr_to_pide() static 2008-03-15 19:17:12 -07:00
parport parport: section fixup 2008-02-13 16:21:19 -08:00
pci pci: revert SMBus unhide on HP Compaq nx6110 2008-03-28 14:45:22 -07:00
pcmcia PCI: drivers/pcmcia/i82092.c: fix up after pci_bus_region changes 2008-02-21 15:34:35 -08:00
pnp pnpacpi: reduce printk severity for "pnpacpi: exceeded the max number of ..." 2008-03-26 14:22:20 -04:00
power Merge branch 'release' of git://git.kernel.org/pub/scm/linux/kernel/git/lenb/linux-acpi-2.6 2008-02-07 09:45:58 -08:00
ps3 [POWERPC] PS3: Update sys-manager button events 2008-02-14 22:11:01 +11:00
rapidio docbook: fix rapidio source files 2008-03-03 10:47:13 -08:00
rtc rtc-at91sam9 fixes 2008-03-19 18:53:37 -07:00
s390 [S390] zcrypt: fix ap_device_list handling 2008-03-05 12:37:19 +01:00
sbus
scsi [SCSI] a100u2w: fix bitmap lookup routine 2008-03-20 09:19:25 -05:00
serial serial: sh-sci: Fix fifo stall on SH7760/SH7780/SH7785 SCIF. 2008-03-11 13:58:50 +09:00
sh maple: fix device detection 2008-02-26 14:12:09 +09:00
sn ioc3.c: replace remaining __FUNCTION__ occurrences 2008-03-17 08:11:48 -04:00
spi spi_bitbang: short transfer status fix 2008-03-13 13:11:43 -07:00
ssb ssb: Add pcibios_enable_device() return value check 2008-03-04 18:36:35 -05:00
tc
telephony
thermal thermal: delete "default y" 2008-03-18 01:22:10 -04:00
uio UIO: add pgprot_noncached() to UIO mmap code 2008-03-24 22:33:49 -07:00
usb USB: ehci: stop vt6212 bus hogging 2008-03-24 22:26:15 -07:00
video blackfin video driver: fix bug when opening/reading/mmaping BF54x and BF52x framebuffer simultaneously 2008-03-28 14:45:22 -07:00
virtio virtio_pci: unregister virtio device at device remove 2008-03-28 11:05:51 +11:00
w1 ds1wm: report bus reset error 2008-03-04 16:35:12 -08:00
watchdog [WATCHDOG] make watchdog/hpwdt.c:asminline_call() static 2008-03-06 21:32:21 +00:00
xen
zorro
Kconfig memstick: initial commit for Sony MemoryStick support 2008-02-09 11:08:34 -08:00
Makefile memstick: initial commit for Sony MemoryStick support 2008-02-09 11:08:34 -08:00