lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20250616060212.1560-1-hanchunchao@inspur.com>
Date: Mon, 16 Jun 2025 14:02:12 +0800
From: Charles Han <hanchunchao@...pur.com>
To: <vkoul@...nel.org>, <vz@...ia.com>, <manabian@...il.com>
CC: <dmaengine@...r.kernel.org>, <linux-arm-kernel@...ts.infradead.org>,
	<linux-kernel@...r.kernel.org>, Charles Han <hanchunchao@...pur.com>
Subject: [PATCH] dmaengine: Add NULL check in lpc18xx_dmamux_reserve()

The function of_find_device_by_node() may return NULL if the device
node is not found or CONFIG_OF not defined.
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@...pur.com>
---
 drivers/dma/lpc18xx-dmamux.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/drivers/dma/lpc18xx-dmamux.c b/drivers/dma/lpc18xx-dmamux.c
index 2b6436f4b193..ef9aed4ba173 100644
--- a/drivers/dma/lpc18xx-dmamux.c
+++ b/drivers/dma/lpc18xx-dmamux.c
@@ -53,11 +53,16 @@ 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);
 	unsigned long flags;
 	unsigned mux;
 
+	struct platform_device *pdev = of_find_device_by_node(ofdma->of_node);
+
+	if (!pdev)
+		return ERR_PTR(-ENODEV);
+
+	struct lpc18xx_dmamux_data *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);
-- 
2.43.0


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ