2023-07-15 15:56:53

by Zhang Shurong

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

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 <[email protected]>
---
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