[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-Id: <20240523121434.21855-4-hyperlyzcs@gmail.com>
Date: Thu, 23 May 2024 20:14:34 +0800
From: Yongzhi Liu <hyperlyzcs@...il.com>
To: kumaravel.thiagarajan@...rochip.com,
vaibhaavram.tl@...rochip.com,
arnd@...db.de,
gregkh@...uxfoundation.org
Cc: linux-gpio@...r.kernel.org,
linux-kernel@...r.kernel.org,
jitxie@...cent.com,
huntazhang@...cent.com,
Yongzhi Liu <hyperlyzcs@...il.com>
Subject: [PATCH 2/2] 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: 393fc2f5948f ("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@...il.com>
---
drivers/misc/mchp_pci1xxxx/mchp_pci1xxxx_gp.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/drivers/misc/mchp_pci1xxxx/mchp_pci1xxxx_gp.c b/drivers/misc/mchp_pci1xxxx/mchp_pci1xxxx_gp.c
index de75d89ef53e..34c9be437432 100644
--- a/drivers/misc/mchp_pci1xxxx/mchp_pci1xxxx_gp.c
+++ b/drivers/misc/mchp_pci1xxxx/mchp_pci1xxxx_gp.c
@@ -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)
--
2.36.1
Powered by blists - more mailing lists