Skip to content

Commit 77427e3

Browse files
Yongzhi Liugregkh
authored andcommitted
misc: microchip: pci1xxxx: Fix a memory leak in the error handling of gp_aux_bus_probe()
There is a memory leak (forget to free allocated buffers) in a memory allocation failure path. Fix it to jump to the correct error handling code. Fixes: 393fc2f ("misc: microchip: pci1xxxx: load auxiliary bus driver for the PIO function in the multi-function endpoint of pci1xxxx device.") Signed-off-by: Yongzhi Liu <[email protected]> Reviewed-by: Kumaravel Thiagarajan <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 086c6cb commit 77427e3

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

drivers/misc/mchp_pci1xxxx/mchp_pci1xxxx_gp.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,10 @@ static int gp_aux_bus_probe(struct pci_dev *pdev, const struct pci_device_id *id
6969

7070
aux_bus->aux_device_wrapper[1] = kzalloc(sizeof(*aux_bus->aux_device_wrapper[1]),
7171
GFP_KERNEL);
72-
if (!aux_bus->aux_device_wrapper[1])
73-
return -ENOMEM;
72+
if (!aux_bus->aux_device_wrapper[1]) {
73+
retval = -ENOMEM;
74+
goto err_aux_dev_add_0;
75+
}
7476

7577
retval = ida_alloc(&gp_client_ida, GFP_KERNEL);
7678
if (retval < 0)

0 commit comments

Comments
 (0)