[PATCH] dmaengine: mv_xor: fix to avoid potential NULL pointer dereference

Zhang Shurong posted 1 patch 2 years, 6 months ago
drivers/dma/mv_xor.c | 3 +++
1 file changed, 3 insertions(+)
[PATCH] dmaengine: mv_xor: fix to avoid potential NULL pointer dereference
Posted by Zhang Shurong 2 years, 6 months ago
of_match_device() may fail and returns a NULL pointer.

Fix this by checking the return value of of_match_device().

Fixes: dd130c652cb7 ("dmaengine: mv_xor: use SoC type instead of directly the operation mode")
Signed-off-by: Zhang Shurong <zhang_shurong@foxmail.com>
---
 drivers/dma/mv_xor.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/dma/mv_xor.c b/drivers/dma/mv_xor.c
index 23b232b57518..317815ec1dd6 100644
--- a/drivers/dma/mv_xor.c
+++ b/drivers/dma/mv_xor.c
@@ -1333,6 +1333,9 @@ static int mv_xor_probe(struct platform_device *pdev)
 			of_match_device(mv_xor_dt_ids,
 					&pdev->dev);
 
+		if (!of_id)
+			return -ENODEV;
+
 		xordev->xor_type = (uintptr_t)of_id->data;
 	}
 
-- 
2.30.2