[PATCH] soc: fsl: qe: Fix potential NULL pointer dereference in qe_reset()

Wang Jun 1742789905 at qq.com
Tue Mar 10 23:11:14 AEDT 2026


The function qe_reset() uses qe_immr without checking if it is NULL,
which could happen if ioremap() failed earlier. Add a NULL check and
perform ioremap() if needed; if it still fails, print an error and
return to avoid crashing the system.

Signed-off-by: Wang Jun <1742789905 at qq.com>
---
 drivers/soc/fsl/qe/qe.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/drivers/soc/fsl/qe/qe.c b/drivers/soc/fsl/qe/qe.c
index 70b6eddb867b..6dcfa340970a 100644
--- a/drivers/soc/fsl/qe/qe.c
+++ b/drivers/soc/fsl/qe/qe.c
@@ -86,8 +86,13 @@ static phys_addr_t get_qe_base(void)
 
 void qe_reset(void)
 {
-	if (qe_immr == NULL)
+	if (qe_immr == NULL) {
 		qe_immr = ioremap(get_qe_base(), QE_IMMAP_SIZE);
+		if (qe_immr == NULL) {
+			pr_err("QE: cannot remap IMMR\n");
+			return;
+		}
+	}
 
 	qe_snums_init();
 
-- 
2.43.0



More information about the Linuxppc-dev mailing list