[PATCH next] dmaengine: idxd: init: Fix uninitialized use of conf_dev in idxd_setup_wqs()

Ziming Du posted 1 patch 2 months, 1 week ago
There is a newer version of this series
drivers/dma/idxd/init.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
[PATCH next] dmaengine: idxd: init: Fix uninitialized use of conf_dev in idxd_setup_wqs()
Posted by Ziming Du 2 months, 1 week ago
Fix Smatch-detected issue:
drivers/dma/idxd/init.c:246 idxd_setup_wqs() error:
uninitialized symbol'conf_dev'

'conf_dev' may be used uninitialized in error handling paths.
Specifically, if the memory allocation for 'wq' fails, the code
jumps to 'err', and attempt to call put_device(conf_dev), without
ensuring that conf_dev has been properly initialized.

Fix it by initializing conf_dev to NULL at declaration.

Signed-off-by: Ziming Du <duziming2@huawei.com>
---
 drivers/dma/idxd/init.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/dma/idxd/init.c b/drivers/dma/idxd/init.c
index 35bdefd3728b..2b61f26af1f6 100644
--- a/drivers/dma/idxd/init.c
+++ b/drivers/dma/idxd/init.c
@@ -178,7 +178,7 @@ static int idxd_setup_wqs(struct idxd_device *idxd)
 {
 	struct device *dev = &idxd->pdev->dev;
 	struct idxd_wq *wq;
-	struct device *conf_dev;
+	struct device *conf_dev = NULL;
 	int i, rc;
 
 	idxd->wqs = kcalloc_node(idxd->max_wqs, sizeof(struct idxd_wq *),
-- 
2.43.0
Re: [PATCH next] dmaengine: idxd: init: Fix uninitialized use of conf_dev in idxd_setup_wqs()
Posted by Dave Jiang 2 months, 1 week ago

On 7/28/25 4:51 AM, Ziming Du wrote:
> Fix Smatch-detected issue:
> drivers/dma/idxd/init.c:246 idxd_setup_wqs() error:
> uninitialized symbol'conf_dev'
> 
> 'conf_dev' may be used uninitialized in error handling paths.
> Specifically, if the memory allocation for 'wq' fails, the code
> jumps to 'err', and attempt to call put_device(conf_dev), without
> ensuring that conf_dev has been properly initialized.
> 
> Fix it by initializing conf_dev to NULL at declaration.
> 
> Signed-off-by: Ziming Du <duziming2@huawei.com>

Reviewed-by: Dave Jiang <dave.jiang@intel.com>
> ---
>  drivers/dma/idxd/init.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/dma/idxd/init.c b/drivers/dma/idxd/init.c
> index 35bdefd3728b..2b61f26af1f6 100644
> --- a/drivers/dma/idxd/init.c
> +++ b/drivers/dma/idxd/init.c
> @@ -178,7 +178,7 @@ static int idxd_setup_wqs(struct idxd_device *idxd)
>  {
>  	struct device *dev = &idxd->pdev->dev;
>  	struct idxd_wq *wq;
> -	struct device *conf_dev;
> +	struct device *conf_dev = NULL;
>  	int i, rc;
>  
>  	idxd->wqs = kcalloc_node(idxd->max_wqs, sizeof(struct idxd_wq *),