* [PATCH v2 1/3] bus/cdx: remove ineffective code statement
2023-06-16 12:39 [PATCH v2 0/3] bus/cdx: fix coverity issue Abhijit Gangurde
@ 2023-06-16 12:39 ` Abhijit Gangurde
2023-06-16 12:39 ` [PATCH v2 2/3] bus/cdx: move debug print before unmapping resource Abhijit Gangurde
` (2 subsequent siblings)
3 siblings, 0 replies; 6+ messages in thread
From: Abhijit Gangurde @ 2023-06-16 12:39 UTC (permalink / raw)
To: Nipun.Gupta, nikhil.agarwal
Cc: dev, david.marchand, ferruh.yigit, Abhijit Gangurde, Nipun Gupta
Remove ineffective code statement ret = 0 since it is
overwritten in a loop.
Coverity issue: 385379
Fixes: 45ef232af515 ("bus/cdx: introduce AMD CDX bus")
Signed-off-by: Abhijit Gangurde <abhijit.gangurde@amd.com>
Acked-by: Nipun Gupta <nipun.gupta@amd.com>
---
v2:
- Updated commit message
drivers/bus/cdx/cdx.c | 1 -
1 file changed, 1 deletion(-)
diff --git a/drivers/bus/cdx/cdx.c b/drivers/bus/cdx/cdx.c
index 28bbf92ed5..9130c30515 100644
--- a/drivers/bus/cdx/cdx.c
+++ b/drivers/bus/cdx/cdx.c
@@ -452,7 +452,6 @@ cdx_probe(void)
dev->name);
rte_errno = errno;
failed++;
- ret = 0;
}
}
--
2.25.1
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH v2 2/3] bus/cdx: move debug print before unmapping resource
2023-06-16 12:39 [PATCH v2 0/3] bus/cdx: fix coverity issue Abhijit Gangurde
2023-06-16 12:39 ` [PATCH v2 1/3] bus/cdx: remove ineffective code statement Abhijit Gangurde
@ 2023-06-16 12:39 ` Abhijit Gangurde
2023-06-16 12:39 ` [PATCH v2 3/3] bus/cdx: fix resource leak Abhijit Gangurde
2023-06-19 3:58 ` [PATCH v2 0/3] bus/cdx: fix coverity issue Nipun Gupta
3 siblings, 0 replies; 6+ messages in thread
From: Abhijit Gangurde @ 2023-06-16 12:39 UTC (permalink / raw)
To: Nipun.Gupta, nikhil.agarwal
Cc: dev, david.marchand, ferruh.yigit, Abhijit Gangurde
Move debug print before unmapping requested address
to fix use after free coverity issue.
Coverity issue: 385381
Fixes: 45ef232af515 ("bus/cdx: introduce AMD CDX bus")
Signed-off-by: Abhijit Gangurde <abhijit.gangurde@amd.com>
---
v2:
- Updated commit message
drivers/bus/cdx/cdx.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/bus/cdx/cdx.c b/drivers/bus/cdx/cdx.c
index 9130c30515..aef19682f4 100644
--- a/drivers/bus/cdx/cdx.c
+++ b/drivers/bus/cdx/cdx.c
@@ -322,12 +322,13 @@ cdx_unmap_resource(void *requested_addr, size_t size)
if (requested_addr == NULL)
return;
+ CDX_BUS_DEBUG("Unmapping CDX memory at %p", requested_addr);
+
/* Unmap the CDX memory resource of device */
if (rte_mem_unmap(requested_addr, size)) {
CDX_BUS_ERR("%s(): cannot mem unmap(%p, %#zx): %s", __func__,
requested_addr, size, rte_strerror(rte_errno));
}
- CDX_BUS_DEBUG("CDX memory unmapped at %p", requested_addr);
}
/*
* Match the CDX Driver and Device using device id and vendor id.
--
2.25.1
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH v2 3/3] bus/cdx: fix resource leak
2023-06-16 12:39 [PATCH v2 0/3] bus/cdx: fix coverity issue Abhijit Gangurde
2023-06-16 12:39 ` [PATCH v2 1/3] bus/cdx: remove ineffective code statement Abhijit Gangurde
2023-06-16 12:39 ` [PATCH v2 2/3] bus/cdx: move debug print before unmapping resource Abhijit Gangurde
@ 2023-06-16 12:39 ` Abhijit Gangurde
2023-06-19 3:58 ` [PATCH v2 0/3] bus/cdx: fix coverity issue Nipun Gupta
3 siblings, 0 replies; 6+ messages in thread
From: Abhijit Gangurde @ 2023-06-16 12:39 UTC (permalink / raw)
To: Nipun.Gupta, nikhil.agarwal
Cc: dev, david.marchand, ferruh.yigit, Abhijit Gangurde
Free the allocated device memory and interrupt handler
on error scenarios.
Coverity issue: 385377
Fixes: f29fb5caa135 ("bus/cdx: support MSI")
Signed-off-by: Abhijit Gangurde <abhijit.gangurde@amd.com>
---
v2:
- Updated commit message
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 aef19682f4..f9526e08cc 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
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v2 0/3] bus/cdx: fix coverity issue
2023-06-16 12:39 [PATCH v2 0/3] bus/cdx: fix coverity issue Abhijit Gangurde
` (2 preceding siblings ...)
2023-06-16 12:39 ` [PATCH v2 3/3] bus/cdx: fix resource leak Abhijit Gangurde
@ 2023-06-19 3:58 ` Nipun Gupta
2023-06-27 21:22 ` Thomas Monjalon
3 siblings, 1 reply; 6+ messages in thread
From: Nipun Gupta @ 2023-06-19 3:58 UTC (permalink / raw)
To: Abhijit Gangurde, nikhil.agarwal; +Cc: dev, david.marchand, ferruh.yigit
Please use in-reply-to while sending subsequent version of patches.
On 6/16/2023 6:09 PM, Abhijit Gangurde wrote:
> This series fixes coverity issues 385379, 385381, 385377
>
> v2:
> - Merged coverity fix patches into series
> - Updated commit message
Series Acked-by: Nipun Gupta <nipun.gupta@amd.com>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v2 0/3] bus/cdx: fix coverity issue
2023-06-19 3:58 ` [PATCH v2 0/3] bus/cdx: fix coverity issue Nipun Gupta
@ 2023-06-27 21:22 ` Thomas Monjalon
0 siblings, 0 replies; 6+ messages in thread
From: Thomas Monjalon @ 2023-06-27 21:22 UTC (permalink / raw)
To: Abhijit Gangurde
Cc: nikhil.agarwal, dev, david.marchand, ferruh.yigit, Nipun Gupta
19/06/2023 05:58, Nipun Gupta:
>
> Please use in-reply-to while sending subsequent version of patches.
>
> On 6/16/2023 6:09 PM, Abhijit Gangurde wrote:
> > This series fixes coverity issues 385379, 385381, 385377
> >
> > v2:
> > - Merged coverity fix patches into series
> > - Updated commit message
>
> Series Acked-by: Nipun Gupta <nipun.gupta@amd.com>
Applied, thanks.
^ permalink raw reply [flat|nested] 6+ messages in thread