* [PATCH] firmware: imx: sm-misc: Add NULL check for kmalloc in syslog_show
@ 2026-06-09 0:45 Li Jun
2026-06-09 15:38 ` Frank Li
0 siblings, 1 reply; 4+ 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] 4+ messages in thread
* Re: [PATCH] firmware: imx: sm-misc: Add NULL check for kmalloc in syslog_show
2026-06-09 0:45 [PATCH] firmware: imx: sm-misc: Add NULL check for kmalloc in syslog_show Li Jun
@ 2026-06-09 15:38 ` Frank Li
0 siblings, 0 replies; 4+ messages in thread
From: Frank Li @ 2026-06-09 15:38 UTC (permalink / raw)
To: Li Jun
Cc: Frank.Li, s.hauer, imx, linux-kernel, kernel, festevam, peng.fan,
shawnguo, krzysztof.kozlowski, linux-arm-kernel
On Tue, Jun 09, 2026 at 08:45:04AM +0800, Li Jun wrote:
>
> 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>
> ---
Add a fix tags
Frank
> 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 [flat|nested] 4+ 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-29 20:41 ` Frank.Li
0 siblings, 1 reply; 4+ 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] 4+ messages in thread* Re: [PATCH] firmware: imx: sm-misc: Add NULL check for kmalloc in syslog_show
2026-06-10 0:38 Li Jun
@ 2026-06-29 20:41 ` Frank.Li
0 siblings, 0 replies; 4+ messages in thread
From: Frank.Li @ 2026-06-29 20:41 UTC (permalink / raw)
To: s.hauer, imx, linux-kernel, kernel, festevam, peng.fan, shawnguo,
krzysztof.kozlowski, linux-arm-kernel, Li Jun
Cc: Frank Li
From: Frank Li <Frank.Li@nxp.com>
On Wed, 10 Jun 2026 08:38:14 +0800, Li Jun wrote:
> 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.
Applied, thanks!
[1/1] firmware: imx: sm-misc: Add NULL check for kmalloc in syslog_show
commit: 4cf26bc2e7e099c86127d63ed7272753da45737e
Best regards,
--
Frank Li <Frank.Li@nxp.com>
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-06-29 20:42 UTC | newest]
Thread overview: 4+ 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 15:38 ` Frank Li
-- strict thread matches above, loose matches on Subject: below --
2026-06-10 0:38 Li Jun
2026-06-29 20:41 ` Frank.Li
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox