linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] pid:fix a return value in alloc_pid
@ 2020-03-11  8:19 tangbin
  2020-03-11  9:12 ` Christian Brauner
  0 siblings, 1 reply; 2+ messages in thread
From: tangbin @ 2020-03-11  8:19 UTC (permalink / raw)
  To: christian.brauner; +Cc: oleg, akpm, linux-kernel, tangbin

When I doing a make about linux-next in X86 right now,it prompts a 
warning about "‘retval’ may be used uninitialized in this function
[-Wmaybe-uninitialized]". So I found that undefined 'retval' initially
in alloc_pid(),so the return ERR_PTR(retval) was an uncertain value.
Kmem_cache_alloc() is for sapce,so it will return ERR_PTR(-ENOMEM) if 
unsuccessful.

Signed-off-by: tangbin <tangbin@cmss.chinamobile.com>
---
 kernel/pid.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/pid.c b/kernel/pid.c
index ff6cd67..f214094 100644
--- a/kernel/pid.c
+++ b/kernel/pid.c
@@ -177,7 +177,7 @@ struct pid *alloc_pid(struct pid_namespace *ns, pid_t *set_tid,
 
 	pid = kmem_cache_alloc(ns->pid_cachep, GFP_KERNEL);
 	if (!pid)
-		return ERR_PTR(retval);
+		return ERR_PTR(-ENOMEM);
 
 	tmp = ns;
 	pid->level = ns->level;
-- 
2.7.4




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

* Re: [PATCH] pid:fix a return value in alloc_pid
  2020-03-11  8:19 [PATCH] pid:fix a return value in alloc_pid tangbin
@ 2020-03-11  9:12 ` Christian Brauner
  0 siblings, 0 replies; 2+ messages in thread
From: Christian Brauner @ 2020-03-11  9:12 UTC (permalink / raw)
  To: tangbin; +Cc: oleg, akpm, linux-kernel

On March 11, 2020 9:19:16 AM GMT+01:00, tangbin <tangbin@cmss.chinamobile.com> wrote:
>When I doing a make about linux-next in X86 right now,it prompts a 
>warning about "‘retval’ may be used uninitialized in this function
>[-Wmaybe-uninitialized]". So I found that undefined 'retval' initially
>in alloc_pid(),so the return ERR_PTR(retval) was an uncertain value.
>Kmem_cache_alloc() is for sapce,so it will return ERR_PTR(-ENOMEM) if 
>unsuccessful.
>
>Signed-off-by: tangbin <tangbin@cmss.chinamobile.com>
>---
> kernel/pid.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
>diff --git a/kernel/pid.c b/kernel/pid.c
>index ff6cd67..f214094 100644
>--- a/kernel/pid.c
>+++ b/kernel/pid.c
>@@ -177,7 +177,7 @@ struct pid *alloc_pid(struct pid_namespace *ns,
>pid_t *set_tid,
> 
> 	pid = kmem_cache_alloc(ns->pid_cachep, GFP_KERNEL);
> 	if (!pid)
>-		return ERR_PTR(retval);
>+		return ERR_PTR(-ENOMEM);
> 
> 	tmp = ns;
> 	pid->level = ns->level;

There's already a fixed version in my tree for this.
https://git.kernel.org/pub/scm/linux/kernel/git/brauner/linux.git/commit/?h=fixes&id=10dab84caf400f2f5f8b010ebb0c7c4272ec5093

Thanks!
Christian

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

end of thread, other threads:[~2020-03-11  9:12 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-03-11  8:19 [PATCH] pid:fix a return value in alloc_pid tangbin
2020-03-11  9:12 ` Christian Brauner

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).