common/qat: fix incorrect size in the parser

Message ID 20250207095832.4032332-1-arkadiuszx.kusztal@intel.com (mailing list archive)
State Superseded
Delegated to: akhil goyal
Headers
Series common/qat: fix incorrect size in the parser |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/loongarch-compilation success Compilation OK
ci/loongarch-unit-testing success Unit Testing PASS
ci/github-robot: build success github build: passed
ci/iol-mellanox-Performance success Performance Testing PASS
ci/iol-marvell-Functional success Functional Testing PASS
ci/iol-abi-testing success Testing PASS
ci/iol-unit-amd64-testing success Testing PASS
ci/iol-compile-amd64-testing success Testing PASS
ci/iol-unit-arm64-testing success Testing PASS
ci/iol-compile-arm64-testing success Testing PASS
ci/Intel-compilation success Compilation OK
ci/intel-Testing success Testing PASS
ci/intel-Functional success Functional PASS
ci/iol-broadcom-Performance success Performance Testing PASS
ci/iol-intel-Performance success Performance Testing PASS
ci/iol-intel-Functional success Functional Testing PASS
ci/iol-sample-apps-testing success Testing PASS

Commit Message

Arkadiusz Kusztal Feb. 7, 2025, 9:58 a.m. UTC
The function `strlen` returns the size of the string without a terminating
null-character, therefore a request to allocate memory space for a parsed
argument is too small by 1.

Fixes: 99ab2806687b ("common/qat: isolate parser arguments configuration")
Cc: stable@dpdk.org

Signed-off-by: Arkadiusz Kusztal <arkadiuszx.kusztal@intel.com>
---
 drivers/common/qat/qat_device.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
  

Comments

Brian Dooley Feb. 19, 2025, 9:41 a.m. UTC | #1
> -----Original Message-----
> From: Kusztal, ArkadiuszX <arkadiuszx.kusztal@intel.com>
> Sent: Friday 7 February 2025 09:59
> To: dev@dpdk.org
> Cc: gakhil@marvell.com; Dooley, Brian <brian.dooley@intel.com>; Kusztal,
> ArkadiuszX <arkadiuszx.kusztal@intel.com>; stable@dpdk.org
> Subject: [PATCH] common/qat: fix incorrect size in the parser
> 
> The function `strlen` returns the size of the string without a terminating null-
> character, therefore a request to allocate memory space for a parsed argument
> is too small by 1.
> 
> Fixes: 99ab2806687b ("common/qat: isolate parser arguments
> configuration")
> Cc: stable@dpdk.org
> 
> Signed-off-by: Arkadiusz Kusztal <arkadiuszx.kusztal@intel.com>
> ---
>  drivers/common/qat/qat_device.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/common/qat/qat_device.c
> b/drivers/common/qat/qat_device.c index bca88fd9bd..746d8a28bb
> 100644
> --- a/drivers/common/qat/qat_device.c
> +++ b/drivers/common/qat/qat_device.c
> @@ -226,7 +226,7 @@ qat_dev_parse_command_line(struct qat_pci_device
> *qat_dev,
>  	if (!devargs)
>  		return 0;
> 
> -	len = strlen(devargs->drv_str);
> +	len = strlen(devargs->drv_str) + 1;
>  	if (len == 0)
>  		return 0;
>  	/* Allocate per-device command line */
> --
> 2.34.1

Acked-by: Brian Dooley <brian.dooley@intel.com>
  
Akhil Goyal March 2, 2025, 7:14 p.m. UTC | #2
> > Subject: [PATCH] common/qat: fix incorrect size in the parser
> >
> > The function `strlen` returns the size of the string without a terminating null-
> > character, therefore a request to allocate memory space for a parsed argument
> > is too small by 1.
> >
> > Fixes: 99ab2806687b ("common/qat: isolate parser arguments
> > configuration")
> > Cc: stable@dpdk.org
> >
> > Signed-off-by: Arkadiusz Kusztal <arkadiuszx.kusztal@intel.com>
> > ---
> >  drivers/common/qat/qat_device.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/drivers/common/qat/qat_device.c
> > b/drivers/common/qat/qat_device.c index bca88fd9bd..746d8a28bb
> > 100644
> > --- a/drivers/common/qat/qat_device.c
> > +++ b/drivers/common/qat/qat_device.c
> > @@ -226,7 +226,7 @@ qat_dev_parse_command_line(struct qat_pci_device
> > *qat_dev,
> >  	if (!devargs)
> >  		return 0;
> >
> > -	len = strlen(devargs->drv_str);
> > +	len = strlen(devargs->drv_str) + 1;
> >  	if (len == 0)
> >  		return 0;

Once len increased by 1, above check is redundant.
You should increment length after if check


> >  	/* Allocate per-device command line */
> > --
> > 2.34.1
> 
> Acked-by: Brian Dooley <brian.dooley@intel.com>
  

Patch

diff --git a/drivers/common/qat/qat_device.c b/drivers/common/qat/qat_device.c
index bca88fd9bd..746d8a28bb 100644
--- a/drivers/common/qat/qat_device.c
+++ b/drivers/common/qat/qat_device.c
@@ -226,7 +226,7 @@  qat_dev_parse_command_line(struct qat_pci_device *qat_dev,
 	if (!devargs)
 		return 0;
 
-	len = strlen(devargs->drv_str);
+	len = strlen(devargs->drv_str) + 1;
 	if (len == 0)
 		return 0;
 	/* Allocate per-device command line */