From: Frank Li <Frank.li@oss.nxp.com>
To: Wentao Liang <vulab@iscas.ac.cn>
Cc: Frank.Li@kernel.org, dmaengine@vger.kernel.org,
george.ge@microchip.com, kelvin.cao@microchip.com,
linux-kernel@vger.kernel.org, logang@deltatee.com,
vkoul@kernel.org, stable@vger.kernel.org
Subject: Re: [PATCH] dmaengine: switchtec-dma: Fix device reference leak in switchtec_dma_create()
Date: Wed, 16 Sep 2026 11:05:30 -0500 [thread overview]
Message-ID: <aqq-SldWxcGqF1Ay@SMW015318> (raw)
In-Reply-To: <20260916093332.2003909-1-vulab@iscas.ac.cn>
On Wed, Sep 16, 2026 at 09:33:32AM +0000, Wentao Liang wrote:
> switchtec_dma_create() takes a reference on the PCI device with
> get_device() and stores it in dma->dev. The reference is normally
> dropped by switchtec_dma_release(), the device_release() callback,
> which only runs after a successful dma_async_device_register(). If
> the registration fails, the code frees the dma device directly from
> the err_chans_release_exit label without ever dropping that extra
> reference, leaking the reference taken on the PCI device.
>
> Drop the reference with put_device() on the error path.
>
> Fixes: d9587042b50f ("dmaengine: switchtec-dma: Introduce Switchtec DMA engine skeleton")
> Cc: stable@vger.kernel.org
> Signed-off-by: Wentao Liang <vulab@iscas.ac.cn>
> ---
> drivers/dma/switchtec_dma.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/drivers/dma/switchtec_dma.c b/drivers/dma/switchtec_dma.c
> index 3ef928640615..b07bdd0ac540 100644
> --- a/drivers/dma/switchtec_dma.c
> +++ b/drivers/dma/switchtec_dma.c
> @@ -1297,6 +1297,7 @@ static int switchtec_dma_create(struct pci_dev *pdev)
>
> err_chans_release_exit:
> switchtec_dma_chans_release(pdev, swdma_dev);
> + put_device(dma->dev);
Does switchtec_dma_remove() also need put_device()?
Frank
>
> err_exit:
> if (swdma_dev->chan_status_irq)
> --
> 2.34.1
>
next prev parent reply other threads:[~2026-09-16 16:05 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-16 9:33 Wentao Liang
2026-09-16 16:05 ` Frank Li [this message]
2026-09-16 17:53 ` 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=aqq-SldWxcGqF1Ay@SMW015318 \
--to=frank.li@oss.nxp.com \
--cc=Frank.Li@kernel.org \
--cc=dmaengine@vger.kernel.org \
--cc=george.ge@microchip.com \
--cc=kelvin.cao@microchip.com \
--cc=linux-kernel@vger.kernel.org \
--cc=logang@deltatee.com \
--cc=stable@vger.kernel.org \
--cc=vkoul@kernel.org \
--cc=vulab@iscas.ac.cn \
/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
all inboxes | Powered by JetHome®