From: Vladimir Zapolskiy <vz@mleia.com>
To: Charles Han <hanchunchao@inspur.com>,
eugen.hristev@linaro.org, vkoul@kernel.org, manabian@gmail.com
Cc: dmaengine@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH V2] dmaengine: Add NULL check in lpc18xx_dmamux_reserve()
Date: Mon, 16 Jun 2025 18:23:58 +0300 [thread overview]
Message-ID: <3ed9f3bc-60f5-4c40-97b5-53d6af4d78c9@mleia.com> (raw)
In-Reply-To: <20250616104420.1720-1-hanchunchao@inspur.com>
On 6/16/25 13:44, Charles Han wrote:
> The function of_find_device_by_node() may return NULL if the device
> node is not found or CONFIG_OF not defined.
DMA_OF depends on OF, and the driver depends on OF as it's stated
in the drivers/dma/Kconfig, so this is not an issue.
Next, is it possible here to get of_find_device_by_node() returning
NULL? I don't think so, and then it's unclear which problem is supposed
to be fixed by this change, and therefore the change should be dropped.
> Add check whether the return value is NULL and set the error code
> to be returned as -ENODEV.
>
> Fixes: e5f4ae84be74 ("dmaengine: add driver for lpc18xx dmamux")
> Signed-off-by: Charles Han <hanchunchao@inspur.com>
> ---
> drivers/dma/lpc18xx-dmamux.c | 10 ++++++++--
> 1 file changed, 8 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/dma/lpc18xx-dmamux.c b/drivers/dma/lpc18xx-dmamux.c
> index 2b6436f4b193..f61183a1d0ba 100644
> --- a/drivers/dma/lpc18xx-dmamux.c
> +++ b/drivers/dma/lpc18xx-dmamux.c
> @@ -53,11 +53,17 @@ static void lpc18xx_dmamux_free(struct device *dev, void *route_data)
> static void *lpc18xx_dmamux_reserve(struct of_phandle_args *dma_spec,
> struct of_dma *ofdma)
> {
> - struct platform_device *pdev = of_find_device_by_node(ofdma->of_node);
> - struct lpc18xx_dmamux_data *dmamux = platform_get_drvdata(pdev);
> + struct platform_device *pdev;
> + struct lpc18xx_dmamux_data *dmamux;
The list of declared/initialized local variables is deliberately sorted
in so called reverse Christmas tree order, please keep the sorting order.
> unsigned long flags;
> unsigned mux;
>
> + pdev = of_find_device_by_node(ofdma->of_node);
> + if (!pdev)
> + return ERR_PTR(-ENODEV);
> +
> + dmamux = platform_get_drvdata(pdev);
> +
> if (dma_spec->args_count != 3) {
> dev_err(&pdev->dev, "invalid number of dma mux args\n");
> return ERR_PTR(-EINVAL);
--
Best wishes,
Vladimir
prev parent reply other threads:[~2025-06-16 15:24 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-06-16 10:44 Charles Han
2025-06-16 11:24 ` Eugen Hristev
2025-06-16 15:23 ` Vladimir Zapolskiy [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=3ed9f3bc-60f5-4c40-97b5-53d6af4d78c9@mleia.com \
--to=vz@mleia.com \
--cc=dmaengine@vger.kernel.org \
--cc=eugen.hristev@linaro.org \
--cc=hanchunchao@inspur.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=manabian@gmail.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
all inboxes | Powered by JetHome®