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: <20250616104810.2222-1-hanchunchao@inspur.com>
Date: Mon, 16 Jun 2025 18:48:10 +0800
From: Charles Han <hanchunchao@...pur.com>
To: <vireshk@...nel.org>, <andriy.shevchenko@...ux.intel.com>,
	<vkoul@...nel.org>, <miquel.raynal@...tlin.com>,
	<ilpo.jarvinen@...ux.intel.com>
CC: <dmaengine@...r.kernel.org>, <linux-kernel@...r.kernel.org>, Charles Han
	<hanchunchao@...pur.com>
Subject: [PATCH] dmaengine: dw: dmamux: Add NULL check in rzn1_dmamux_route_allocate()

The function of_find_device_by_node() may return NULL if the device
node cannot be found or 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: 134d9c52fca2 ("dmaengine: dw: dmamux: Introduce RZN1 DMA router support")
Signed-off-by: Charles Han <hanchunchao@...pur.com>
---
 drivers/dma/dw/rzn1-dmamux.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/drivers/dma/dw/rzn1-dmamux.c b/drivers/dma/dw/rzn1-dmamux.c
index 4fb8508419db..a21623d98e41 100644
--- a/drivers/dma/dw/rzn1-dmamux.c
+++ b/drivers/dma/dw/rzn1-dmamux.c
@@ -41,13 +41,19 @@ static void rzn1_dmamux_free(struct device *dev, void *route_data)
 static void *rzn1_dmamux_route_allocate(struct of_phandle_args *dma_spec,
 					struct of_dma *ofdma)
 {
-	struct platform_device *pdev = of_find_device_by_node(ofdma->of_node);
-	struct rzn1_dmamux_data *dmamux = platform_get_drvdata(pdev);
+	struct platform_device *pdev;
+	struct rzn1_dmamux_data *dmamux;
 	struct rzn1_dmamux_map *map;
 	unsigned int dmac_idx, chan, val;
 	u32 mask;
 	int ret;
 
+	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 != RNZ1_DMAMUX_NCELLS)
 		return ERR_PTR(-EINVAL);
 
-- 
2.43.0


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ