Linux kernel and device drivers for NXP i.MX platforms
 help / color / mirror / Atom feed
* [PATCH] firmware: imx: sm-misc: Add NULL check for kmalloc in syslog_show
@ 2026-06-09  0:45 Li Jun
  2026-06-09  0:59 ` sashiko-bot
  2026-06-09 15:38 ` Frank Li
  0 siblings, 2 replies; 7+ messages in thread
From: Li Jun @ 2026-06-09  0:45 UTC (permalink / raw)
  To: lijun01, Frank.Li, s.hauer, imx, linux-kernel, kernel, festevam,
	peng.fan, shawnguo, krzysztof.kozlowski, linux-arm-kernel

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.

Signed-off-by: Li Jun <lijun01@kylinos.cn>
---
 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;
 
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 7+ messages in thread
* [PATCH] firmware: imx: sm-misc: Add NULL check for kmalloc in syslog_show
@ 2026-06-10  0:38 Li Jun
  2026-06-10  0:48 ` sashiko-bot
  0 siblings, 1 reply; 7+ messages in thread
From: Li Jun @ 2026-06-10  0:38 UTC (permalink / raw)
  To: lijun01, Frank.Li, s.hauer, imx, linux-kernel, kernel, festevam,
	peng.fan, shawnguo, krzysztof.kozlowski, linux-arm-kernel

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 <lijun01@kylinos.cn>
---
 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;
 
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 7+ messages in thread
* [PATCH] firmware: imx: sm-misc: Add NULL check for kmalloc in syslog_show
@ 2026-06-08  2:03 Li Jun
  2026-06-08  2:17 ` sashiko-bot
  0 siblings, 1 reply; 7+ messages in thread
From: Li Jun @ 2026-06-08  2:03 UTC (permalink / raw)
  To: lijun01, Frank.Li, s.hauer, imx, linux-kernel

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.

Signed-off-by: Li Jun <lijun01@kylinos.cn>
---
 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;
 
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2026-06-10  0:48 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-06-09  0:45 [PATCH] firmware: imx: sm-misc: Add NULL check for kmalloc in syslog_show Li Jun
2026-06-09  0:59 ` sashiko-bot
2026-06-09 15:38 ` Frank Li
  -- strict thread matches above, loose matches on Subject: below --
2026-06-10  0:38 Li Jun
2026-06-10  0:48 ` sashiko-bot
2026-06-08  2:03 Li Jun
2026-06-08  2:17 ` sashiko-bot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox