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

misc: microchip: pci1xxxx: Fix a memory leak in the error handling of gp_aux_bus_probe()

'aux_bus' is freed in the remove function but not in the error handling
path of the probe.

Use devm_kzalloc() to simplify the remove function and fix the leak in the
probe.

Fixes: 393fc2f5948f ("misc: microchip: pci1xxxx: load auxiliary bus driver for the PIO function in the multi-function endpoint of pci1xxxx device.")
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Link: https://lore.kernel.org/r/17e19926669a1654e5f2495bf3b289581183d02e.1663482259.git.christophe.jaillet@wanadoo.fr
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Christophe JAILLET and committed by
Greg Kroah-Hartman
62e5d006 c8b47475

+1 -2
+1 -2
drivers/misc/mchp_pci1xxxx/mchp_pci1xxxx_gp.c
··· 38 38 if (retval) 39 39 return retval; 40 40 41 - aux_bus = kzalloc(sizeof(*aux_bus), GFP_KERNEL); 41 + aux_bus = devm_kzalloc(&pdev->dev, sizeof(*aux_bus), GFP_KERNEL); 42 42 if (!aux_bus) 43 43 return -ENOMEM; 44 44 ··· 138 138 auxiliary_device_uninit(&aux_bus->aux_device_wrapper[0]->aux_dev); 139 139 auxiliary_device_delete(&aux_bus->aux_device_wrapper[1]->aux_dev); 140 140 auxiliary_device_uninit(&aux_bus->aux_device_wrapper[1]->aux_dev); 141 - kfree(aux_bus); 142 141 } 143 142 144 143 static const struct pci_device_id pci1xxxx_tbl[] = {