Skip to content

Commit 029c3c1

Browse files
Jesper Juhlgregkh
authored andcommitted
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>
1 parent 8845256 commit 029c3c1

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

‎drivers/pci/hotplug/ibmphp_core.c‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,8 +148,10 @@ int ibmphp_init_devno(struct slot **cur_slot)
148148
len = (rtable->size - sizeof(struct irq_routing_table)) /
149149
sizeof(struct irq_info);
150150

151-
if (!len)
151+
if (!len) {
152+
kfree(rtable);
152153
return -1;
154+
}
153155
for (loop = 0; loop < len; loop++) {
154156
if ((*cur_slot)->number == rtable->slots[loop].slot) {
155157
if ((*cur_slot)->bus == rtable->slots[loop].bus) {
@@ -187,11 +189,13 @@ int ibmphp_init_devno(struct slot **cur_slot)
187189
debug("rtable->slots[loop].irq[3].link = %x\n",
188190
rtable->slots[loop].irq[3].link);
189191
debug("end of init_devno\n");
192+
kfree(rtable);
190193
return 0;
191194
}
192195
}
193196
}
194197

198+
kfree(rtable);
195199
return -1;
196200
}
197201

0 commit comments

Comments
 (0)