All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] proc: bootconfig: add null pointer check
@ 2022-03-29 10:40 cgel.zte
  2022-03-29 14:21 ` Masami Hiramatsu
  2022-03-29 14:30 ` Masami Hiramatsu
  0 siblings, 2 replies; 4+ messages in thread
From: cgel.zte @ 2022-03-29 10:40 UTC (permalink / raw)
  To: mhiramat; +Cc: linux-kernel, linux-fsdevel, Lv Ruyi, Zeal Robot

From: Lv Ruyi <lv.ruyi@zte.com.cn>

kzalloc is a memory allocation function which can return NULL when some
internal memory errors happen. It is safer to add null pointer check.

Reported-by: Zeal Robot <zealci@zte.com.cn>
Signed-off-by: Lv Ruyi <lv.ruyi@zte.com.cn>
---
 fs/proc/bootconfig.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/fs/proc/bootconfig.c b/fs/proc/bootconfig.c
index 6d8d4bf20837..2e244ada1f97 100644
--- a/fs/proc/bootconfig.c
+++ b/fs/proc/bootconfig.c
@@ -32,6 +32,8 @@ static int __init copy_xbc_key_value_list(char *dst, size_t size)
 	int ret = 0;
 
 	key = kzalloc(XBC_KEYLEN_MAX, GFP_KERNEL);
+	if (!key)
+		return -ENOMEM;
 
 	xbc_for_each_key_value(leaf, val) {
 		ret = xbc_node_compose_key(leaf, key, XBC_KEYLEN_MAX);
-- 
2.25.1


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

* Re: [PATCH] proc: bootconfig: add null pointer check
  2022-03-29 10:40 [PATCH] proc: bootconfig: add null pointer check cgel.zte
@ 2022-03-29 14:21 ` Masami Hiramatsu
  2022-03-29 14:30 ` Masami Hiramatsu
  1 sibling, 0 replies; 4+ messages in thread
From: Masami Hiramatsu @ 2022-03-29 14:21 UTC (permalink / raw)
  To: cgel.zte; +Cc: linux-kernel, linux-fsdevel, Lv Ruyi, Zeal Robot

On Tue, 29 Mar 2022 10:40:04 +0000
cgel.zte@gmail.com wrote:

> From: Lv Ruyi <lv.ruyi@zte.com.cn>
> 
> kzalloc is a memory allocation function which can return NULL when some
> internal memory errors happen. It is safer to add null pointer check.

Oops, yes.

Acked-by: Masami Hiramatsu <mhiramat@kernel.org>

Thank you!

> 
> Reported-by: Zeal Robot <zealci@zte.com.cn>
> Signed-off-by: Lv Ruyi <lv.ruyi@zte.com.cn>
> ---
>  fs/proc/bootconfig.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/fs/proc/bootconfig.c b/fs/proc/bootconfig.c
> index 6d8d4bf20837..2e244ada1f97 100644
> --- a/fs/proc/bootconfig.c
> +++ b/fs/proc/bootconfig.c
> @@ -32,6 +32,8 @@ static int __init copy_xbc_key_value_list(char *dst, size_t size)
>  	int ret = 0;
>  
>  	key = kzalloc(XBC_KEYLEN_MAX, GFP_KERNEL);
> +	if (!key)
> +		return -ENOMEM;
>  
>  	xbc_for_each_key_value(leaf, val) {
>  		ret = xbc_node_compose_key(leaf, key, XBC_KEYLEN_MAX);
> -- 
> 2.25.1
> 


-- 
Masami Hiramatsu <mhiramat@kernel.org>

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

* Re: [PATCH] proc: bootconfig: add null pointer check
  2022-03-29 10:40 [PATCH] proc: bootconfig: add null pointer check cgel.zte
  2022-03-29 14:21 ` Masami Hiramatsu
@ 2022-03-29 14:30 ` Masami Hiramatsu
  2022-03-29 14:46   ` Steven Rostedt
  1 sibling, 1 reply; 4+ messages in thread
From: Masami Hiramatsu @ 2022-03-29 14:30 UTC (permalink / raw)
  To: Steven Rostedt; +Cc: cgel.zte, linux-kernel, linux-fsdevel, Lv Ruyi, Zeal Robot

Hi Steve,

Can you pick this with below lines? This seems to be there from v5.6.

Fixes: c1a3c36017d4 ("proc: bootconfig: Add /proc/bootconfig to show boot config list")
Cc: stable@vger.kernel.org
Acked-by: Masami Hiramatsu <mhiramat@kernel.org>

Thank you,

On Tue, 29 Mar 2022 10:40:04 +0000
cgel.zte@gmail.com wrote:

> From: Lv Ruyi <lv.ruyi@zte.com.cn>
> 
> kzalloc is a memory allocation function which can return NULL when some
> internal memory errors happen. It is safer to add null pointer check.
> 
> Reported-by: Zeal Robot <zealci@zte.com.cn>
> Signed-off-by: Lv Ruyi <lv.ruyi@zte.com.cn>
> ---
>  fs/proc/bootconfig.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/fs/proc/bootconfig.c b/fs/proc/bootconfig.c
> index 6d8d4bf20837..2e244ada1f97 100644
> --- a/fs/proc/bootconfig.c
> +++ b/fs/proc/bootconfig.c
> @@ -32,6 +32,8 @@ static int __init copy_xbc_key_value_list(char *dst, size_t size)
>  	int ret = 0;
>  
>  	key = kzalloc(XBC_KEYLEN_MAX, GFP_KERNEL);
> +	if (!key)
> +		return -ENOMEM;
>  
>  	xbc_for_each_key_value(leaf, val) {
>  		ret = xbc_node_compose_key(leaf, key, XBC_KEYLEN_MAX);
> -- 
> 2.25.1
> 


-- 
Masami Hiramatsu <mhiramat@kernel.org>

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

* Re: [PATCH] proc: bootconfig: add null pointer check
  2022-03-29 14:30 ` Masami Hiramatsu
@ 2022-03-29 14:46   ` Steven Rostedt
  0 siblings, 0 replies; 4+ messages in thread
From: Steven Rostedt @ 2022-03-29 14:46 UTC (permalink / raw)
  To: Masami Hiramatsu
  Cc: cgel.zte, linux-kernel, linux-fsdevel, Lv Ruyi, Zeal Robot

On Tue, 29 Mar 2022 23:30:53 +0900
Masami Hiramatsu <mhiramat@kernel.org> wrote:

> Hi Steve,
> 
> Can you pick this with below lines? This seems to be there from v5.6.
> 
> Fixes: c1a3c36017d4 ("proc: bootconfig: Add /proc/bootconfig to show boot config list")
> Cc: stable@vger.kernel.org
> Acked-by: Masami Hiramatsu <mhiramat@kernel.org>
> 
> 

Sure.

-- Steve

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

end of thread, other threads:[~2022-03-29 14:46 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-29 10:40 [PATCH] proc: bootconfig: add null pointer check cgel.zte
2022-03-29 14:21 ` Masami Hiramatsu
2022-03-29 14:30 ` Masami Hiramatsu
2022-03-29 14:46   ` Steven Rostedt

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.