Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

PCI: Hotplug: Fix leaks in IBM Hot Plug Controller Driver - ibmphp_init_devno()

In drivers/pci/hotplug/ibmphp_core.c::ibmphp_init_devno() we allocate
space dynamically for a PCI irq routing table by calling
pcibios_get_irq_routing_table(), but we never free the allocated space.

This patch frees the allocated space at the function exit points.

Spotted by the Coverity checker. Compile tested only.

Please consider applying.

Signed-off-by: Jesper Juhl <jesper.juhl@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>

authored by

Jesper Juhl and committed by
Greg Kroah-Hartman
029c3c13 88452565

+5 -1
+5 -1
drivers/pci/hotplug/ibmphp_core.c
··· 148 148 len = (rtable->size - sizeof(struct irq_routing_table)) / 149 149 sizeof(struct irq_info); 150 150 151 - if (!len) 151 + if (!len) { 152 + kfree(rtable); 152 153 return -1; 154 + } 153 155 for (loop = 0; loop < len; loop++) { 154 156 if ((*cur_slot)->number == rtable->slots[loop].slot) { 155 157 if ((*cur_slot)->bus == rtable->slots[loop].bus) { ··· 189 187 debug("rtable->slots[loop].irq[3].link = %x\n", 190 188 rtable->slots[loop].irq[3].link); 191 189 debug("end of init_devno\n"); 190 + kfree(rtable); 192 191 return 0; 193 192 } 194 193 } 195 194 } 196 195 196 + kfree(rtable); 197 197 return -1; 198 198 } 199 199