[PATCH v1] bus/ifpga: fix issue of accessing null address

Zhang, Tianfei tianfei.zhang at intel.com
Mon Mar 20 07:34:02 CET 2023



> -----Original Message-----
> From: Huang, Wei <wei.huang at intel.com>
> Sent: Friday, March 17, 2023 4:44 AM
> To: dev at dpdk.org; thomas at monjalon.net; david.marchand at redhat.com
> Cc: stable at dpdk.org; Xu, Rosen <rosen.xu at intel.com>; Zhang, Tianfei
> <tianfei.zhang at intel.com>; Zhang, Qi Z <qi.z.zhang at intel.com>; Huang, Wei
> <wei.huang at intel.com>
> Subject: [PATCH v1] bus/ifpga: fix issue of accessing null address
> 
> In function ifpga_scan_one(), variable 'path' is NULL if device argument 'afu_bts' is
> not set, subsequent string copy with 'path' would lead to segmentation fault.
> 
> Fixes: 6fa4aa2b3645 ("bus/ifpga: fix forcing optional devargs")
> Cc: stable at dpdk.org
> 
> Signed-off-by: Wei Huang <wei.huang at intel.com>
> ---
>  drivers/bus/ifpga/ifpga_bus.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/bus/ifpga/ifpga_bus.c b/drivers/bus/ifpga/ifpga_bus.c index
> bb943b5..07e316b 100644
> --- a/drivers/bus/ifpga/ifpga_bus.c
> +++ b/drivers/bus/ifpga/ifpga_bus.c
> @@ -135,6 +135,8 @@ struct rte_afu_device *
>  			goto end;
>  		}
>  		afu_pr_conf.pr_enable = 1;
> +		strlcpy(afu_pr_conf.bs_path, path,
> +			sizeof(afu_pr_conf.bs_path));
>  	} else {
>  		afu_pr_conf.pr_enable = 0;
>  	}
> @@ -174,7 +176,6 @@ struct rte_afu_device *
>  		rawdev->dev_ops->dev_start(rawdev))
>  		goto end;
> 
> -	strlcpy(afu_pr_conf.bs_path, path, sizeof(afu_pr_conf.bs_path));
>  	if (rawdev->dev_ops &&
>  		rawdev->dev_ops->firmware_load &&
>  		rawdev->dev_ops->firmware_load(rawdev,
> --
> 1.8.3.1

It looks good for me.
Acked-by: Tianfei Zhang <tianfei.zhang at intel.com>



More information about the stable mailing list