aboutsummaryrefslogtreecommitdiff
path: root/drivers/misc
diff options
context:
space:
mode:
authorGravatar Christophe JAILLET <christophe.jaillet@wanadoo.fr> 2022-09-18 08:27:33 +0200
committerGravatar Greg Kroah-Hartman <gregkh@linuxfoundation.org> 2022-09-22 16:54:35 +0200
commit62e5d00684ef81b4be35d23e54eec92ee38db7b8 (patch)
tree7a8cbfef7667fb94b3da61253e49ff06e50b0a51 /drivers/misc
parentmisc: microchip: pci1xxxx: Do not disable the pci device twice in gp_aux_bus_... (diff)
downloadlinux-62e5d00684ef81b4be35d23e54eec92ee38db7b8.tar.gz
linux-62e5d00684ef81b4be35d23e54eec92ee38db7b8.tar.bz2
linux-62e5d00684ef81b4be35d23e54eec92ee38db7b8.zip
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>
Diffstat (limited to 'drivers/misc')
-rw-r--r--drivers/misc/mchp_pci1xxxx/mchp_pci1xxxx_gp.c3
1 files changed, 1 insertions, 2 deletions
diff --git a/drivers/misc/mchp_pci1xxxx/mchp_pci1xxxx_gp.c b/drivers/misc/mchp_pci1xxxx/mchp_pci1xxxx_gp.c
index 6c4f8384aa09..32af2b14ff34 100644
--- a/drivers/misc/mchp_pci1xxxx/mchp_pci1xxxx_gp.c
+++ b/drivers/misc/mchp_pci1xxxx/mchp_pci1xxxx_gp.c
@@ -38,7 +38,7 @@ static int gp_aux_bus_probe(struct pci_dev *pdev, const struct pci_device_id *id
if (retval)
return retval;
- aux_bus = kzalloc(sizeof(*aux_bus), GFP_KERNEL);
+ aux_bus = devm_kzalloc(&pdev->dev, sizeof(*aux_bus), GFP_KERNEL);
if (!aux_bus)
return -ENOMEM;
@@ -138,7 +138,6 @@ static void gp_aux_bus_remove(struct pci_dev *pdev)
auxiliary_device_uninit(&aux_bus->aux_device_wrapper[0]->aux_dev);
auxiliary_device_delete(&aux_bus->aux_device_wrapper[1]->aux_dev);
auxiliary_device_uninit(&aux_bus->aux_device_wrapper[1]->aux_dev);
- kfree(aux_bus);
}
static const struct pci_device_id pci1xxxx_tbl[] = {