All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Lorenzo Stoakes (ARM)" <ljs@kernel.org>
To: "David Hildenbrand (Arm)" <david@kernel.org>
Cc: Hongfu Li <lihongfu@kylinos.cn>,
	 Andrew Morton <akpm@linux-foundation.org>,
	"Liam R. Howlett" <liam@infradead.org>,
	 Vlastimil Babka <vbabka@kernel.org>,
	Mike Rapoport <rppt@kernel.org>,
	 Suren Baghdasaryan <surenb@google.com>,
	Michal Hocko <mhocko@suse.com>, Shuah Khan <shuah@kernel.org>,
	 hongfu.li@linux.dev, linux-mm@kvack.org,
	linux-kselftest@vger.kernel.org,  linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2] selftests/mm: mlock2-tests: fix fclose(NULL) in is_vmflag_set()
Date: Fri, 13 Nov 2026 13:03:13 +0000	[thread overview]
Message-ID: <avcKibrnNmJn47fL@gremlin> (raw)
In-Reply-To: <fb5ebeaf-2e3a-4d5a-9fb1-e86c1f10252f@kernel.org>

On Fri, Nov 13, 2026 at 11:31:55AM +0100, David Hildenbrand (Arm) wrote:
> On 11/13/26 03:52, Hongfu Li wrote:
> > is_vmflag_set() jumps to the shared 'out' label when
> > seek_to_smaps_entry() fails. smaps is NULL on that path, and the
> > code at the 'out' label calls fclose(smaps) unconditionally.
> > fclose(NULL) is undefined behaviour, so the test crashes before
> > it can report a test result.
>
> I was briefly confuses staring at get_value_for_name() diff below. WHich is
> clarified below.
>
> >
> > Return early on that error path instead, so smaps is always valid
> > at the 'out' label.
> >
> > get_value_for_name() follows the same pattern. Return early on the
> > seek_to_smaps_entry() error path there as well, and drop the now
> > redundant 'if (smaps)' guard on the fclose().
> >
> > Signed-off-by: Hongfu Li <lihongfu@kylinos.cn>
>
> Fixes: tag? :)
>
> Apart form that LGTM
>
> Reviewed-by: David Hildenbrand (Arm) <david@kernel.org>

Similarly,

Reviewed-by: Lorenzo Stoakes (ARM) <ljs@kernel.org>

>
> --
> Cheers,
>
> David

--
Cheers, Lorenzo

      reply	other threads:[~2026-11-13 13:03 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-13  2:52 [PATCH v2] selftests/mm: mlock2-tests: fix fclose(NULL) in is_vmflag_set() Hongfu Li
2026-11-13 10:31 ` David Hildenbrand (Arm)
2026-11-13 13:03   ` Lorenzo Stoakes (ARM) [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=avcKibrnNmJn47fL@gremlin \
    --to=ljs@kernel.org \
    --cc=akpm@linux-foundation.org \
    --cc=david@kernel.org \
    --cc=hongfu.li@linux.dev \
    --cc=liam@infradead.org \
    --cc=lihongfu@kylinos.cn \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=mhocko@suse.com \
    --cc=rppt@kernel.org \
    --cc=shuah@kernel.org \
    --cc=surenb@google.com \
    --cc=vbabka@kernel.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.