lkml.org 
[lkml]   [2021]   [Dec]   [12]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [PATCH] cgroup: check the return value of kstrdup()
From
Date
On Mon, 2021-12-13 at 11:30 +0800, Xiaoke Wang wrote:
> kstrdup() returns NULL when some internal memory errors happen, it is
> better to check the return value of it so to catch the memory error in
> time.
[]
> diff --git a/kernel/cgroup/cgroup.c b/kernel/cgroup/cgroup.c
[]
> @@ -2228,6 +2228,9 @@ static int cpuset_init_fs_context(struct fs_context *fc)
> struct cgroup_fs_context *ctx;
> int err;
>
> + if (!agent)
> + return -ENOMEM;
> +

Did you read all the other code that uses this?
Does it matter if it's NULL?
Why is it created with kstrdup in the first place?
Why should agent be anything other than const char *?
If it's const char * it shouldn't need to be used with
kstrdup/kfree.


\
 
 \ /
  Last update: 2021-12-13 05:33    [W:0.041 / U:0.024 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site