From: Logan Gunthorpe <logang@deltatee.com>
To: Miaoqian Lin <linmq006@gmail.com>, Vinod Koul <vkoul@kernel.org>,
Dan Carpenter <error27@gmail.com>,
dmaengine@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] dmaengine: plx_dma: Fix potential double free in plx_dma_create
Date: Tue, 20 Dec 2022 09:35:38 -0700 [thread overview]
Message-ID: <31659f35-453e-2a5a-2f93-e35ef1395ad7@deltatee.com> (raw)
In-Reply-To: <20221220061752.1120381-1-linmq006@gmail.com>
On 2022-12-19 23:17, Miaoqian Lin wrote:
> When all references are dropped, callback function plx_dma_release()
> for put_device() will call kfree(plxdev) to release memory.
> Fix the error path to fix the possible double free.
>
> Fixes: 07503e6aefe4 ("dmaengine: plx_dma: add a missing put_device() on error path")
> Signed-off-by: Miaoqian Lin <linmq006@gmail.com>
> ---
> Please correct me if I make mistakes, thanks for your review.
> ---
> drivers/dma/plx_dma.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/dma/plx_dma.c b/drivers/dma/plx_dma.c
> index 12725fa1655f..bce724ff4e16 100644
> --- a/drivers/dma/plx_dma.c
> +++ b/drivers/dma/plx_dma.c
> @@ -546,8 +546,9 @@ static int plx_dma_create(struct pci_dev *pdev)
> return 0;
>
> put_device:
> - put_device(&pdev->dev);
> free_irq(pci_irq_vector(pdev, 0), plxdev);
> + put_device(&pdev->dev);
> + return rc;
> free_plx:
> kfree(plxdev);
>
Sorry, after reviewing, I don't think this patch is correct.
plx_dma_release() is called from dma_async_device_unregister() which
won't be called if dma_async_device_register() fails. It does not get
freed when the pci device is put. So I don't think this is a possible
double free.
Logan
next prev parent reply other threads:[~2022-12-20 16:35 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-12-20 6:17 [PATCH] dmaengine: plx_dma: Fix potential double free in plx_dma_create Miaoqian Lin
2022-12-20 16:35 ` Logan Gunthorpe [this message]
2022-12-23 10:42 ` Dan Carpenter
2022-12-23 18:17 ` Logan Gunthorpe
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=31659f35-453e-2a5a-2f93-e35ef1395ad7@deltatee.com \
--to=logang@deltatee.com \
--cc=dmaengine@vger.kernel.org \
--cc=error27@gmail.com \
--cc=linmq006@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.