From: David Finkel <davidf@vimeo.com>
To: Philip Li <philip.li@intel.com>
Cc: Andrew Morton <akpm@linux-foundation.org>,
kernel test robot <lkp@intel.com>,
oe-kbuild-all@lists.linux.dev,
Linux Memory Management List <linux-mm@kvack.org>
Subject: Re: [akpm-mm:mm-unstable 36/78] test_memcontrol.c:201:6: warning: variable 'fd4_closed' is used uninitialized whenever 'if' condition is true
Date: Mon, 29 Jul 2024 09:45:19 -0400 [thread overview]
Message-ID: <CAFUnj5NoDGAd1y-8N3ikPwZdk6Ujb2OG8kq-fcnOjF52AXA=jg@mail.gmail.com> (raw)
In-Reply-To: <Zqb8f4ldSvBgHd2h@rli9-mobl>
On Sun, Jul 28, 2024 at 10:21 PM Philip Li <philip.li@intel.com> wrote:
>
> On Sun, Jul 28, 2024 at 01:18:24PM -0700, Andrew Morton wrote:
> > On Sun, 28 Jul 2024 11:58:47 +0800 kernel test robot <lkp@intel.com> wrote:
> >
> > > tree: https://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm.git mm-unstable
> > > head: b39b3892d20a337489c55806f91af581474f3943
> > > commit: f2db5cca8182337f4ad485ebfd532b1a2d1c223a [36/78] mm, memcg: cg2 memory{.swap,}.peak write tests
> > > :::::: branch date: 2 days ago
> > > :::::: commit date: 3 days ago
> > > compiler: clang version 18.1.5 (https://github.com/llvm/llvm-project 617a15a9eac96088ae5e9134248d8236e34b91b1)
> > > reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240727/202407272301.bBC2CidR-lkp@intel.com/reproduce)
> > >
> > > If you fix the issue in a separate patch/commit (i.e. not just a new version of
> > > the same patch/commit), kindly add following tags
> > > | Reported-by: kernel test robot <lkp@intel.com>
> > > | Closes: https://lore.kernel.org/r/202407272301.bBC2CidR-lkp@intel.com/
> > >
> > > All warnings (new ones prefixed by >>):
> > >
> > > >> test_memcontrol.c:201:6: warning: variable 'fd4_closed' is used uninitialized whenever 'if' condition is true [-Wsometimes-uninitialized]
> >
> > um,
> >
> > bool fd2_closed = false, fd3_closed = false, fd4_closed = false;
> >
> > fd4_closed cannot possibly be used uninitialized?
>
> One possible flow is early peak_fd fails to open and go to cleanup, then
> in cleanup side, the variable like fd4_closed is directly used.
Thanks for pointing that out!
My next patchset will move that line to the top of the function.
(Looks like the same issue is present for f2_closed and fd_3_closed)
>
> + if (peak_fd == -1)
> + goto cleanup;
> +
> + bool fd2_closed = false, fd3_closed = false, fd4_closed = false;
> + int peak_fd2 = cg_open(memcg, "memory.peak", O_RDWR | O_APPEND | O_CLOEXEC);
> +
> ...
>
> cleanup:
> + close(peak_fd);
> + if (!fd2_closed)
> + close(peak_fd2);
> + if (!fd3_closed)
> + close(peak_fd3);
> + if (!fd4_closed)
> + close(peak_fd4);
>
> >
--
David Finkel
Senior Principal Software Engineer, Core Services
prev parent reply other threads:[~2024-07-29 13:45 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-07-28 3:58 kernel test robot
2024-07-28 20:18 ` Andrew Morton
2024-07-29 2:20 ` Philip Li
2024-07-29 13:45 ` David Finkel [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='CAFUnj5NoDGAd1y-8N3ikPwZdk6Ujb2OG8kq-fcnOjF52AXA=jg@mail.gmail.com' \
--to=davidf@vimeo.com \
--cc=akpm@linux-foundation.org \
--cc=linux-mm@kvack.org \
--cc=lkp@intel.com \
--cc=oe-kbuild-all@lists.linux.dev \
--cc=philip.li@intel.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