[v3,2/8] bus/dpaa: fix resource leak in variable dev

Message ID 20240708072945.2376209-3-vanshika.shukla@nxp.com (mailing list archive)
State Superseded, archived
Delegated to: Thomas Monjalon
Headers
Series DPAA specific fixes |

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

Vanshika Shukla July 8, 2024, 7:29 a.m. UTC
From: Apeksha Gupta <apeksha.gupta@nxp.com>

Resource leak:
variable dev is going out of scope leaks the storage.

Fixes: d61138d4f0e2 ("drivers: remove direct access to interrupt handle")
Cc: hkalra@marvell.com
Cc: stable@dpdk.org

Signed-off-by: Apeksha Gupta <apeksha.gupta@nxp.com>
Signed-off-by: Vanshika Shukla <vanshika.shukla@nxp.com>
---
 drivers/bus/dpaa/dpaa_bus.c | 2 ++
 1 file changed, 2 insertions(+)
  

Comments

David Marchand July 8, 2024, 1:28 p.m. UTC | #1
On Mon, Jul 8, 2024 at 9:29 AM <vanshika.shukla@nxp.com> wrote:
>
> From: Apeksha Gupta <apeksha.gupta@nxp.com>
>
> Resource leak:
> variable dev is going out of scope leaks the storage.
>
> Fixes: d61138d4f0e2 ("drivers: remove direct access to interrupt handle")
> Cc: hkalra@marvell.com
> Cc: stable@dpdk.org
>
> Signed-off-by: Apeksha Gupta <apeksha.gupta@nxp.com>
> Signed-off-by: Vanshika Shukla <vanshika.shukla@nxp.com>

This lgtm.
Was this issue detected by the public CI coverity?
If so, please add a Coverity ID: tag.
  

Patch

diff --git a/drivers/bus/dpaa/dpaa_bus.c b/drivers/bus/dpaa/dpaa_bus.c
index b8f41ec069..1f6997c77e 100644
--- a/drivers/bus/dpaa/dpaa_bus.c
+++ b/drivers/bus/dpaa/dpaa_bus.c
@@ -188,6 +188,7 @@  dpaa_create_device_list(void)
 		if (dev->intr_handle == NULL) {
 			DPAA_BUS_LOG(ERR, "Failed to allocate intr handle");
 			ret = -ENOMEM;
+			free(dev);
 			goto cleanup;
 		}
 
@@ -239,6 +240,7 @@  dpaa_create_device_list(void)
 		if (dev->intr_handle == NULL) {
 			DPAA_BUS_LOG(ERR, "Failed to allocate intr handle");
 			ret = -ENOMEM;
+			free(dev);
 			goto cleanup;
 		}