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: <20250616104639.1935-1-hanchunchao@inspur.com>
Date: Mon, 16 Jun 2025 18:46:39 +0800
From: Charles Han <hanchunchao@...pur.com>
To: <vkoul@...nel.org>, <vz@...ia.com>, <piotr.wojtaszczyk@...esys.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 lpc32xx_dmamux_reserve()

The function of_find_device_by_node() may return NULL if the device
node cannot be found or if CONFIG_OF is not defined, dereferencing
it without NULL check may lead to NULL dereference.
Add a check to verify whether the return value is NULL.

Fixes: 5d318b595982 ("dmaengine: Add dma router for pl08x in LPC32XX SoC")
Signed-off-by: Charles Han <hanchunchao@...pur.com>
---
 drivers/dma/lpc32xx-dmamux.c | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/drivers/dma/lpc32xx-dmamux.c b/drivers/dma/lpc32xx-dmamux.c
index 351d7e23e615..6dc67d2f3335 100644
--- a/drivers/dma/lpc32xx-dmamux.c
+++ b/drivers/dma/lpc32xx-dmamux.c
@@ -90,13 +90,20 @@ static void lpc32xx_dmamux_release(struct device *dev, void *route_data)
 static void *lpc32xx_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 device *dev = &pdev->dev;
-	struct lpc32xx_dmamux_data *dmamux = platform_get_drvdata(pdev);
+	struct platform_device *pdev;
+	struct device *dev;
+	struct lpc32xx_dmamux_data *dmamux;
 	unsigned long flags;
 	struct lpc32xx_dmamux *mux = NULL;
 	int i;
 
+	pdev = of_find_device_by_node(ofdma->of_node);
+	if (!pdev)
+		return ERR_PTR(-ENODEV);
+
+	dev = &pdev->dev;
+	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