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: 80a4062e88 ("firmware: imx: sm-misc: Dump syslog info")
Signed-off-by: Li Jun <lijun01@kylinos.cn>
Signed-off-by: Frank Li <Frank.Li@nxp.com>
This commit is contained in:
Li Jun 2026-06-10 08:38:14 +08:00 committed by Frank Li
parent 3de939b2ac
commit 4cf26bc2e7

View File

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