public inbox for dmaengine@vger.kernel.org
 help / color / mirror / Atom feed
From: "Péter Ujfalusi" <peter.ujfalusi@gmail.com>
To: Yang Yingliang <yangyingliang@huawei.com>, dmaengine@vger.kernel.org
Cc: vigneshr@ti.com, peter.ujfalusi@ti.com, vkoul@kernel.org
Subject: Re: [PATCH] dmaengine: ti: k3-udma-glue: fix memory leak when register device fail
Date: Wed, 26 Oct 2022 20:14:27 +0300	[thread overview]
Message-ID: <3f65b0f1-119e-2956-b909-d3860d0f12f0@gmail.com> (raw)
In-Reply-To: <20221020062827.2914148-1-yangyingliang@huawei.com>



On 20/10/2022 09:28, Yang Yingliang wrote:
> If device_register() fails, it should call put_device() to give
> up reference, the name allocated in dev_set_name() can be freed
> in callback function kobject_cleanup().

Acked-by: Peter Ujfalusi <peter.ujfalusi@gmail.com>

> 
> Fixes: 5b65781d06ea ("dmaengine: ti: k3-udma-glue: Add support for K3 PKTDMA")
> Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
> ---
>   drivers/dma/ti/k3-udma-glue.c | 3 +++
>   1 file changed, 3 insertions(+)
> 
> diff --git a/drivers/dma/ti/k3-udma-glue.c b/drivers/dma/ti/k3-udma-glue.c
> index 4fdd9f06b723..4f1aeb81e9c7 100644
> --- a/drivers/dma/ti/k3-udma-glue.c
> +++ b/drivers/dma/ti/k3-udma-glue.c
> @@ -299,6 +299,7 @@ struct k3_udma_glue_tx_channel *k3_udma_glue_request_tx_chn(struct device *dev,
>   	ret = device_register(&tx_chn->common.chan_dev);
>   	if (ret) {
>   		dev_err(dev, "Channel Device registration failed %d\n", ret);
> +		put_device(&tx_chn->common.chan_dev);
>   		tx_chn->common.chan_dev.parent = NULL;
>   		goto err;
>   	}
> @@ -917,6 +918,7 @@ k3_udma_glue_request_rx_chn_priv(struct device *dev, const char *name,
>   	ret = device_register(&rx_chn->common.chan_dev);
>   	if (ret) {
>   		dev_err(dev, "Channel Device registration failed %d\n", ret);
> +		put_device(&rx_chn->common.chan_dev);
>   		rx_chn->common.chan_dev.parent = NULL;
>   		goto err;
>   	}
> @@ -1048,6 +1050,7 @@ k3_udma_glue_request_remote_rx_chn(struct device *dev, const char *name,
>   	ret = device_register(&rx_chn->common.chan_dev);
>   	if (ret) {
>   		dev_err(dev, "Channel Device registration failed %d\n", ret);
> +		put_device(&rx_chn->common.chan_dev);
>   		rx_chn->common.chan_dev.parent = NULL;
>   		goto err;
>   	}

-- 
Péter

  reply	other threads:[~2022-10-26 17:13 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-20  6:28 [PATCH] dmaengine: ti: k3-udma-glue: fix memory leak when register device fail Yang Yingliang
2022-10-26 17:14 ` Péter Ujfalusi [this message]
2022-11-04 14:38 ` Vinod Koul

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=3f65b0f1-119e-2956-b909-d3860d0f12f0@gmail.com \
    --to=peter.ujfalusi@gmail.com \
    --cc=dmaengine@vger.kernel.org \
    --cc=peter.ujfalusi@ti.com \
    --cc=vigneshr@ti.com \
    --cc=vkoul@kernel.org \
    --cc=yangyingliang@huawei.com \
    /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