From: John Hubbard <jhubbard@nvidia.com>
To: Christian Brauner <christian.brauner@ubuntu.com>
Cc: Stephen Rothwell <sfr@canb.auug.org.au>,
Linux Next <linux-next@vger.kernel.org>,
LKML <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] pid: fix uninitialized retval in alloc_pid()
Date: Tue, 10 Mar 2020 20:33:31 -0700 [thread overview]
Message-ID: <e9eed2e9-5bcf-1978-3776-b8b25f92ac5b@nvidia.com> (raw)
In-Reply-To: <20200311033021.qm26c6cltfndlx3c@wittgenstein>
On 3/10/20 8:30 PM, Christian Brauner wrote:
> On Tue, Mar 10, 2020 at 08:21:53PM -0700, John Hubbard wrote:
>> Commit 8deb24dcb89cb ("pid: make ENOMEM return value more obvious")
>> left the return value uninitialized in one error case. The justification
>> for the above commit included a statement that retval is "initialized on
>> ever[y] failure path in the loop". However, that is not quite good
>> enough because there is an earlier case that is before the loop. And
>> also, it's more maintenance and merge-safe to initialize it once at the
>> top, as evidenced by this build warning that we now have.
>>
>> Therefore, restore the top-level initialization of retval.
>>
>> Also move the descriptive comment up, and remove the now-redundant
>> later initialization of retval.
>>
>> Fixes: 8deb24dcb89cb ("pid: make ENOMEM return value more obvious")
>> Cc: Christian Brauner <christian.brauner@ubuntu.com>
>> Signed-off-by: John Hubbard <jhubbard@nvidia.com>
>
> Thanks. I already have a fixed-up version in my tree after Stephen
> reported it earlier today:
> https://git.kernel.org/pub/scm/linux/kernel/git/brauner/linux.git/commit/?h=fixes&id=10dab84caf400f2f5f8b010ebb0c7c4272ec5093
>
> (Fwiw, we can't just move the it back up. It needs to be set after the
> loop too because it can be set to EPERM before. See
OK, yes. Sounds good.
thanks,
--
John Hubbard
NVIDIA
> https://git.kernel.org/pub/scm/linux/kernel/git/brauner/linux.git/commit/?h=fixes&id=b26ebfe12f34f372cf041c6f801fa49c3fb382c5
> for the motiviation for the comment.)
>
> Christian
>
prev parent reply other threads:[~2020-03-11 3:33 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-03-11 3:21 [PATCH] pid: fix uninitialized retval in alloc_pid() John Hubbard
2020-03-11 3:30 ` Christian Brauner
2020-03-11 3:33 ` John Hubbard [this message]
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=e9eed2e9-5bcf-1978-3776-b8b25f92ac5b@nvidia.com \
--to=jhubbard@nvidia.com \
--cc=christian.brauner@ubuntu.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-next@vger.kernel.org \
--cc=sfr@canb.auug.org.au \
/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