linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Lorenzo Stoakes <lorenzo.stoakes@oracle.com>
To: Dan Carpenter <dan.carpenter@linaro.org>
Cc: linux-mm@kvack.org
Subject: Re: [bug report] mm/mremap: complete refactor of move_vma()
Date: Wed, 25 Jun 2025 16:28:51 +0100	[thread overview]
Message-ID: <01784ef6-1520-4a00-8539-e1705c1be7d6@lucifer.local> (raw)
In-Reply-To: <2f035b94-ab84-427a-b8a0-5f0274e8b8b9@sabinyo.mountain>

On Wed, Jun 25, 2025 at 10:22:49AM -0500, Dan Carpenter wrote:
> Hello Lorenzo Stoakes,
>
> The patch b714ccb02a76: "mm/mremap: complete refactor of move_vma()"
> from Mar 10, 2025, leads to the following static checker warning:
>
> 	mm/mremap.c:1920 move_vma()
> 	error: uninitialized symbol 'new_vma'.
>
> mm/mremap.c
>     1895 static unsigned long move_vma(struct vma_remap_struct *vrm)
>     1896 {
>     1897 	struct mm_struct *mm = current->mm;
>     1898 	struct vm_area_struct *new_vma;
>     1899 	unsigned long hiwater_vm;
>     1900 	int err;
>     1901
>     1902 	err = prep_move_vma(vrm);
>     1903 	if (err)
>     1904 		return err;
>     1905
>     1906 	/* If accounted, charge the number of bytes the operation will use. */
>     1907 	if (!vrm_charge(vrm))
>     1908 		return -ENOMEM;
>     1909
>     1910 	/* We don't want racing faults. */
>     1911 	vma_start_write(vrm->vma);
>     1912
>     1913 	/* Perform copy step. */
>     1914 	err = copy_vma_and_data(vrm, &new_vma);
>     1915 	/*
>     1916 	 * If we established the copied-to VMA, we attempt to recover from the
>     1917 	 * error by setting the destination VMA to the source VMA and unmapping
>     1918 	 * it below.
>     1919 	 */
> --> 1920 	if (err && !new_vma)
>                             ^^^^^^^
> new_vma isn't set on the first error path in copy_vma_and_data().

Hmm, the first error path is:

	if (!new_vma) {
		vrm_uncharge(vrm);
		*new_vma_ptr = NULL;
		return -ENOMEM;
	}

Which explicitly sets new_vma = NULL (new_vma_ptr = &new_vma)

The final return there is:

	*new_vma_ptr = new_vma;
	return err;

Which also sets it.

So I'm not sure what's wrong here? Am I missing something?

>
>     1921 		return err;
>     1922
>     1923 	/*
>     1924 	 * If we failed to move page tables we still do total_vm increment
>     1925 	 * since do_munmap() will decrement it by old_len == new_len.
>     1926 	 *
>     1927 	 * Since total_vm is about to be raised artificially high for a
>
> regards,
> dan carpenter
>


  reply	other threads:[~2025-06-25 15:29 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-06-25 15:22 Dan Carpenter
2025-06-25 15:28 ` Lorenzo Stoakes [this message]
2025-06-25 15:35   ` Dan Carpenter
2025-06-25 15:41     ` Lorenzo Stoakes

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=01784ef6-1520-4a00-8539-e1705c1be7d6@lucifer.local \
    --to=lorenzo.stoakes@oracle.com \
    --cc=dan.carpenter@linaro.org \
    --cc=linux-mm@kvack.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