From: Abhijit Gangurde <abhijit.gangurde@amd.com>
To: <Nipun.Gupta@amd.com>, <nikhil.agarwal@amd.com>
Cc: <dev@dpdk.org>, <david.marchand@redhat.com>,
<ferruh.yigit@amd.com>,
Abhijit Gangurde <abhijit.gangurde@amd.com>
Subject: [PATCH] bus/cdx: Fix resource leak
Date: Wed, 14 Jun 2023 15:54:24 +0530 [thread overview]
Message-ID: <20230614102424.224679-1-abhijit.gangurde@amd.com> (raw)
Freeing the allocated resources on error scenarios.
Coverity issue: 385377
Fixes: f29fb5caa135 ("bus/cdx: support MSI")
Signed-off-by: Abhijit Gangurde <abhijit.gangurde@amd.com>
---
drivers/bus/cdx/cdx.c | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/drivers/bus/cdx/cdx.c b/drivers/bus/cdx/cdx.c
index 28bbf92ed5..0f643ad2cb 100644
--- a/drivers/bus/cdx/cdx.c
+++ b/drivers/bus/cdx/cdx.c
@@ -208,8 +208,8 @@ cdx_scan_one(const char *dirname, const char *dev_name)
ret = cdx_get_kernel_driver_by_path(filename, driver, sizeof(driver));
if (ret < 0) {
CDX_BUS_ERR("Fail to get kernel driver");
- ret = -1;
- goto err;
+ free(dev);
+ return -1;
}
/* Allocate interrupt instance for cdx device */
@@ -218,6 +218,7 @@ cdx_scan_one(const char *dirname, const char *dev_name)
if (dev->intr_handle == NULL) {
CDX_BUS_ERR("Failed to create interrupt instance for %s",
dev->device.name);
+ free(dev);
return -ENOMEM;
}
@@ -241,8 +242,8 @@ cdx_scan_one(const char *dirname, const char *dev_name)
/* get device id */
snprintf(filename, sizeof(filename), "%s/device", dirname);
if (eal_parse_sysfs_value(filename, &tmp) < 0) {
- free(dev);
- return -1;
+ ret = -1;
+ goto err;
}
dev->id.device_id = (uint16_t)tmp;
@@ -251,6 +252,7 @@ cdx_scan_one(const char *dirname, const char *dev_name)
return 0;
err:
+ rte_intr_instance_free(dev->intr_handle);
free(dev);
return ret;
}
--
2.25.1
reply other threads:[~2023-06-14 10:24 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230614102424.224679-1-abhijit.gangurde@amd.com \
--to=abhijit.gangurde@amd.com \
--cc=Nipun.Gupta@amd.com \
--cc=david.marchand@redhat.com \
--cc=dev@dpdk.org \
--cc=ferruh.yigit@amd.com \
--cc=nikhil.agarwal@amd.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).