From 4cf26bc2e7e099c86127d63ed7272753da45737e Mon Sep 17 00:00:00 2001 From: Li Jun Date: Wed, 10 Jun 2026 08:38:14 +0800 Subject: [PATCH] firmware: imx: sm-misc: Add NULL check for kmalloc in syslog_show Add a proper NULL check for the kmalloc() return value in syslog_show(). If memory allocation fails, syslog would be NULL and passing it to misc_syslog() could lead to a NULL pointer dereference. Fixes: 80a4062e8821 ("firmware: imx: sm-misc: Dump syslog info") Signed-off-by: Li Jun Signed-off-by: Frank Li --- drivers/firmware/imx/sm-misc.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/firmware/imx/sm-misc.c b/drivers/firmware/imx/sm-misc.c index ac9af824c2d4..fb8d7bdb5b08 100644 --- a/drivers/firmware/imx/sm-misc.c +++ b/drivers/firmware/imx/sm-misc.c @@ -79,6 +79,9 @@ static int syslog_show(struct seq_file *file, void *priv) u16 size = SZ_4K / 4; int ret; + if (!syslog) + return -ENOMEM; + if (!ph) return -ENODEV;