From: Vinod Koul <vkoul@kernel.org>
To: Kunwu Chan <chentao@kylinos.cn>
Cc: dmaengine@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] dmaengine: Add a null pointer check to the dma_request_chan
Date: Mon, 22 Jan 2024 16:55:20 +0530 [thread overview]
Message-ID: <Za5QoCO_o0duPJ4J@matsya> (raw)
In-Reply-To: <20240118033052.193282-1-chentao@kylinos.cn>
On 18-01-24, 11:30, Kunwu Chan wrote:
> kasprintf() returns a pointer to dynamically allocated memory
> which can be NULL upon failure. Ensure the allocation was successful
> by checking the pointer validity.
>
> Signed-off-by: Kunwu Chan <chentao@kylinos.cn>
> ---
> drivers/dma/dmaengine.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/drivers/dma/dmaengine.c b/drivers/dma/dmaengine.c
> index 491b22240221..a6f808d13aa4 100644
> --- a/drivers/dma/dmaengine.c
> +++ b/drivers/dma/dmaengine.c
> @@ -856,6 +856,8 @@ struct dma_chan *dma_request_chan(struct device *dev, const char *name)
> #ifdef CONFIG_DEBUG_FS
> chan->dbg_client_name = kasprintf(GFP_KERNEL, "%s:%s", dev_name(dev),
> name);
> + if (!chan->dbg_client_name)
> + return chan;
That is wrong, you cant return a half done channel here
Pls see rest of the code for reference
> #endif
>
> chan->name = kasprintf(GFP_KERNEL, "dma:%s", name);
> --
> 2.39.2
--
~Vinod
next prev parent reply other threads:[~2024-01-22 11:25 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-01-18 3:30 [PATCH] dmaengine: Add a null pointer check to the dma_request_chan Kunwu Chan
2024-01-22 11:25 ` Vinod Koul [this message]
2024-01-23 8:00 ` Kunwu Chan
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=Za5QoCO_o0duPJ4J@matsya \
--to=vkoul@kernel.org \
--cc=chentao@kylinos.cn \
--cc=dmaengine@vger.kernel.org \
--cc=linux-kernel@vger.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