linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Walter Wu <walter-zh.wu@mediatek.com>
To: Andrew Morton <akpm@linux-foundation.org>,
	Christian Brauner <christian@brauner.io>,
	Oleg Nesterov <oleg@redhat.com>
Cc: <linux-kernel@vger.kernel.org>,
	<linux-arm-kernel@lists.infradead.org>,
	wsd_upstream <wsd_upstream@mediatek.com>,
	Walter Wu <walter-zh.wu@mediatek.com>
Subject: [PATCH] pid: fix uninitialized var warnings
Date: Wed, 11 Mar 2020 20:20:49 +0800	[thread overview]
Message-ID: <20200311122049.11589-1-walter-zh.wu@mediatek.com> (raw)

Compiling with gcc-9.2.1 points out below warnings. Fix it.

kernel/pid.c: In function 'alloc_pid':
kernel/pid.c:180:10: warning: 'retval' may be used uninitialized
in this function [-Wmaybe-uninitialized]

Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Christian Brauner <christian@brauner.io>
Cc: Oleg Nesterov <oleg@redhat.com>
Signed-off-by: Walter Wu <walter-zh.wu@mediatek.com>
---
 kernel/pid.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/kernel/pid.c b/kernel/pid.c
index ff6cd6786d10..02944cfd4e51 100644
--- a/kernel/pid.c
+++ b/kernel/pid.c
@@ -176,8 +176,10 @@ struct pid *alloc_pid(struct pid_namespace *ns, pid_t *set_tid,
 		return ERR_PTR(-EINVAL);
 
 	pid = kmem_cache_alloc(ns->pid_cachep, GFP_KERNEL);
-	if (!pid)
+	if (!pid) {
+		retval = -ENOMEM;
 		return ERR_PTR(retval);
+	}
 
 	tmp = ns;
 	pid->level = ns->level;
-- 
2.18.0

             reply	other threads:[~2020-03-11 12:21 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-03-11 12:20 Walter Wu [this message]
2020-03-11 12:24 ` [PATCH] pid: fix uninitialized var warnings Christian Brauner

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200311122049.11589-1-walter-zh.wu@mediatek.com \
    --to=walter-zh.wu@mediatek.com \
    --cc=akpm@linux-foundation.org \
    --cc=christian@brauner.io \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=oleg@redhat.com \
    --cc=wsd_upstream@mediatek.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).