DMA Engine development
 help / color / mirror / Atom feed
From: Shuai Xue <xueshuai@linux.alibaba.com>
To: Guangshuo Li <lgs201920130244@gmail.com>,
	Vinicius Costa Gomes <vinicius.gomes@intel.com>,
	Dave Jiang <dave.jiang@intel.com>, Vinod Koul <vkoul@kernel.org>,
	Fenghua Yu <fenghuay@nvidia.com>,
	dmaengine@vger.kernel.org, linux-kernel@vger.kernel.org
Cc: stable@vger.kernel.org
Subject: Re: [PATCH] dmaengine: idxd: fix double free in idxd_setup_groups() error path
Date: Thu, 2 Apr 2026 09:44:35 +0800	[thread overview]
Message-ID: <c08c7151-b696-45e3-9465-fb92b3dd9958@linux.alibaba.com> (raw)
In-Reply-To: <20260401033622.1446904-1-lgs201920130244@gmail.com>



On 4/1/26 11:36 AM, Guangshuo Li wrote:
> When an error happens after device_initialize(), idxd_setup_groups()
> calls put_device(conf_dev).
> 
> The device release callback idxd_conf_group_release() frees group, but
> the current error paths then call kfree(group) again, causing a double
> free.
> 
> Keep the cleanup in idxd_conf_group_release() after put_device() and
> avoid freeing group again in idxd_setup_groups().
> 
> Fixes: aa6f4f945b10 ("dmaengine: idxd: fix memory leak in error handling path of idxd_setup_groups")
> Cc: stable@vger.kernel.org
> Signed-off-by: Guangshuo Li <lgs201920130244@gmail.com>
> ---
>   drivers/dma/idxd/init.c | 4 ++--
>   1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/dma/idxd/init.c b/drivers/dma/idxd/init.c
> index b782eb3c191d..d9a9d56dd277 100644
> --- a/drivers/dma/idxd/init.c
> +++ b/drivers/dma/idxd/init.c
> @@ -374,7 +374,7 @@ static int idxd_setup_groups(struct idxd_device *idxd)
>   		rc = dev_set_name(conf_dev, "group%d.%d", idxd->id, group->id);
>   		if (rc < 0) {
>   			put_device(conf_dev);
> -			kfree(group);
> +
>   			goto err;
>   		}
>   
> @@ -399,7 +399,7 @@ static int idxd_setup_groups(struct idxd_device *idxd)
>   	while (--i >= 0) {
>   		group = idxd->groups[i];
>   		put_device(group_confdev(group));
> -		kfree(group);
> +
>   	}
>   	kfree(idxd->groups);
>   

Note that idxd_clean_groups() and idxd_clean_engines() have the same pattern.
It should be fixed in the same patch as well.

Thanks.
Shuai


      parent reply	other threads:[~2026-04-02  1:44 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-04-01  3:36 [PATCH] dmaengine: idxd: fix double free in idxd_setup_groups() error path Guangshuo Li
2026-04-02  1:32 ` Shuai Xue
2026-04-02  1:44 ` Shuai Xue [this message]

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=c08c7151-b696-45e3-9465-fb92b3dd9958@linux.alibaba.com \
    --to=xueshuai@linux.alibaba.com \
    --cc=dave.jiang@intel.com \
    --cc=dmaengine@vger.kernel.org \
    --cc=fenghuay@nvidia.com \
    --cc=lgs201920130244@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=stable@vger.kernel.org \
    --cc=vinicius.gomes@intel.com \
    --cc=vkoul@kernel.org \
    /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