Skip to content

Commit

Permalink
misc: microchip: pci1xxxx: Fix a memory leak in the error handling of…
Browse files Browse the repository at this point in the history
… 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 <hyperlyzcs@gmail.com>
Reviewed-by: Kumaravel Thiagarajan <kumaravel.thiagarajan@microchip.com>
Link: https://lore.kernel.org/r/20240523121434.21855-4-hyperlyzcs@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
Yongzhi Liu authored and Greg Kroah-Hartman committed Jun 4, 2024
1 parent 086c6cb commit 77427e3
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions drivers/misc/mchp_pci1xxxx/mchp_pci1xxxx_gp.c
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,10 @@ static int gp_aux_bus_probe(struct pci_dev *pdev, const struct pci_device_id *id

aux_bus->aux_device_wrapper[1] = kzalloc(sizeof(*aux_bus->aux_device_wrapper[1]),
GFP_KERNEL);
if (!aux_bus->aux_device_wrapper[1])
return -ENOMEM;
if (!aux_bus->aux_device_wrapper[1]) {
retval = -ENOMEM;
goto err_aux_dev_add_0;
}

retval = ida_alloc(&gp_client_ida, GFP_KERNEL);
if (retval < 0)
Expand Down

0 comments on commit 77427e3

Please sign in to comment.