linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: "Colin King (gmail)" <colin.i.king@gmail.com>
To: Andrew Morton <akpm@linux-foundation.org>,
	Linux-MM <linux-mm@kvack.org>, Hugh Dickins <hughd@google.com>,
	"Matthew Wilcox (Oracle)" <willy@infradead.org>
Cc: "linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: re: mm/shmem: turn shmem_alloc_page() into shmem_alloc_folio()
Date: Wed, 4 May 2022 14:36:36 +0100	[thread overview]
Message-ID: <9a206b6b-bb60-b86b-666d-c75748237cf0@gmail.com> (raw)

Hi,

Static analysis with clang scan-build found an issue in the following 
commit:

commit b0bb08b2d5f399369a906eff0287e64b531881d8
Author: Matthew Wilcox (Oracle) <willy@infradead.org>
Date:   Fri Apr 29 14:43:02 2022 -0700

     mm/shmem: turn shmem_alloc_page() into shmem_alloc_folio()


The issue is as follows:

#ifdef CONFIG_USERFAULTFD
int shmem_mfill_atomic_pte(struct mm_struct *dst_mm,
                            pmd_t *dst_pmd,
                            struct vm_area_struct *dst_vma,
                            unsigned long dst_addr,
                            unsigned long src_addr,
                            bool zeropage, bool wp_copy,
                            struct page **pagep)
{
         struct inode *inode = file_inode(dst_vma->vm_file);
         struct shmem_inode_info *info = SHMEM_I(inode);
         struct address_space *mapping = inode->i_mapping;
         gfp_t gfp = mapping_gfp_mask(mapping);
         pgoff_t pgoff = linear_page_index(dst_vma, dst_addr);
         void *page_kaddr;
         struct folio *folio;
         struct page *page;

         ^^ page is not intialized

         int ret;
         pgoff_t max_off;

         if (!shmem_inode_acct_block(inode, 1)) {
                 /*
                  * We may have got a page, returned -ENOENT triggering 
a retry,
                  * and now we find ourselves with -ENOMEM. Release the 
page, to
                  * avoid a BUG_ON in our caller.
                  */
                 if (unlikely(*pagep)) {
                         put_page(*pagep);
                         *pagep = NULL;
                 }
                 return -ENOMEM;
         }

         if (!*pagep) {
                 ret = -ENOMEM;
                 if (!page)
                         goto out_unacct_blocks;

                 ^^ page is being referenced but it has not been set


The commit in question removed the assignment to page:

         if (!*pagep) {
                 ret = -ENOMEM;
-               page = shmem_alloc_page(gfp, info, pgoff);
                 if (!page)
                         goto out_unacct_blocks;


Colin


                 reply	other threads:[~2022-05-04 13:36 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=9a206b6b-bb60-b86b-666d-c75748237cf0@gmail.com \
    --to=colin.i.king@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=hughd@google.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=willy@infradead.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox