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

From: Zhang Shurong
Date: Sat Jul 15 2023 - 11:43:13 EST


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@xxxxxxxxxxx>
---
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