linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Matthew Wilcox <willy@infradead.org>
To: Dan Carpenter <dan.carpenter@linaro.org>
Cc: oe-kbuild@lists.linux.dev, Zi Yan <ziy@nvidia.com>,
	lkp@intel.com, oe-kbuild-all@lists.linux.dev,
	linux-kernel@vger.kernel.org,
	Andrew Morton <akpm@linux-foundation.org>,
	Linux Memory Management List <linux-mm@kvack.org>,
	Baolin Wang <baolin.wang@linux.alibaba.com>
Subject: Re: mm/shmem.c:2223 shmem_split_large_entry() error: uninitialized symbol 'entry_order'.
Date: Wed, 18 Jun 2025 18:47:57 +0100	[thread overview]
Message-ID: <aFL7zYgdMoqNbJBS@casper.infradead.org> (raw)
In-Reply-To: <428fa0fe-8960-4566-9054-5bfd967c18c8@suswa.mountain>

On Wed, Jun 18, 2025 at 08:42:17PM +0300, Dan Carpenter wrote:
> smatch warnings:
> mm/shmem.c:2223 shmem_split_large_entry() error: uninitialized symbol 'entry_order'.

...

> 12885cbe88ddf6 Baolin Wang 2024-08-12  2169  		if (!xa_is_value(old) || swp_to_radix_entry(swap) != old) {
> 12885cbe88ddf6 Baolin Wang 2024-08-12  2170  			xas_set_err(&xas, -EEXIST);
> 12885cbe88ddf6 Baolin Wang 2024-08-12  2171  			goto unlock;
> 
> Imagine we hit this goto on the first iteration

That can happen (but if it does, we set -EEXIST in the xa_state).

> 12885cbe88ddf6 Baolin Wang 2024-08-12  2213  unlock:
> 12885cbe88ddf6 Baolin Wang 2024-08-12  2214  		xas_unlock_irq(&xas);
> 12885cbe88ddf6 Baolin Wang 2024-08-12  2215  
> 12885cbe88ddf6 Baolin Wang 2024-08-12  2216  		if (!xas_nomem(&xas, gfp))
> 12885cbe88ddf6 Baolin Wang 2024-08-12  2217  			break;
> 
> And we hit this break.

That's guaranteed.  If there's an errno in the xa_state that isn't
-ENOMEM, xas_nomem() will fail.

> 12885cbe88ddf6 Baolin Wang 2024-08-12  2218  	}
> 12885cbe88ddf6 Baolin Wang 2024-08-12  2219  
> 12885cbe88ddf6 Baolin Wang 2024-08-12  2220  	if (xas_error(&xas))
> 12885cbe88ddf6 Baolin Wang 2024-08-12  2221  		return xas_error(&xas);
> 12885cbe88ddf6 Baolin Wang 2024-08-12  2222  
> d53c78fffe7ad3 Zi Yan      2025-03-14 @2223  	return entry_order;

but if this does happen, then xas_error() will be true and we'll return
-EEXIST here instead of returning entry_order.


  reply	other threads:[~2025-06-18 17:48 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-06-18 17:42 mm/shmem.c:2223 shmem_split_large_entry() error: uninitialized symbol 'entry_order' Dan Carpenter
2025-06-18 17:47 ` Matthew Wilcox [this message]
2025-06-18 17:53   ` Zi Yan

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=aFL7zYgdMoqNbJBS@casper.infradead.org \
    --to=willy@infradead.org \
    --cc=akpm@linux-foundation.org \
    --cc=baolin.wang@linux.alibaba.com \
    --cc=dan.carpenter@linaro.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=lkp@intel.com \
    --cc=oe-kbuild-all@lists.linux.dev \
    --cc=oe-kbuild@lists.linux.dev \
    --cc=ziy@nvidia.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).