Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 029c3c13 authored by Jesper Juhl's avatar Jesper Juhl Committed by Greg Kroah-Hartman
Browse files

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: default avatarJesper Juhl <jesper.juhl@gmail.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent 88452565
Loading
Loading
Loading
Loading
+5 −1
Original line number Original line Diff line number Diff line
@@ -148,8 +148,10 @@ int ibmphp_init_devno(struct slot **cur_slot)
	len = (rtable->size - sizeof(struct irq_routing_table)) /
	len = (rtable->size - sizeof(struct irq_routing_table)) /
			sizeof(struct irq_info);
			sizeof(struct irq_info);


	if (!len)
	if (!len) {
		kfree(rtable);
		return -1;
		return -1;
	}
	for (loop = 0; loop < len; loop++) {
	for (loop = 0; loop < len; loop++) {
		if ((*cur_slot)->number == rtable->slots[loop].slot) {
		if ((*cur_slot)->number == rtable->slots[loop].slot) {
		if ((*cur_slot)->bus == rtable->slots[loop].bus) {
		if ((*cur_slot)->bus == rtable->slots[loop].bus) {
@@ -187,11 +189,13 @@ int ibmphp_init_devno(struct slot **cur_slot)
				debug("rtable->slots[loop].irq[3].link = %x\n",
				debug("rtable->slots[loop].irq[3].link = %x\n",
					rtable->slots[loop].irq[3].link);
					rtable->slots[loop].irq[3].link);
				debug("end of init_devno\n");
				debug("end of init_devno\n");
				kfree(rtable);
				return 0;
				return 0;
			}
			}
		}
		}
	}
	}


	kfree(rtable);
	return -1;
	return -1;
}
}