linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Barry Song <21cnbao@gmail.com>
To: hailong.liu@oppo.com
Cc: akpm@linux-foundation.org, urezki@gmail.com, hch@infradead.org,
	 lstoakes@gmail.com, linux-mm@kvack.org,
	linux-kernel@vger.kernel.org
Subject: Re: [RFC PATCH v2] mm/vmalloc: fix return value of vb_alloc if size is 0.
Date: Mon, 22 Apr 2024 11:46:26 +0800	[thread overview]
Message-ID: <CAGsJ_4zUhnAAUb77ktJxDvAQpZhGrs00+8iQU3dhwpy=C_CjDA@mail.gmail.com> (raw)
In-Reply-To: <20240419101643.11534-1-hailong.liu@oppo.com>

On Fri, Apr 19, 2024 at 6:17 PM <hailong.liu@oppo.com> wrote:
>
> From: "Hailong.Liu" <hailong.liu@oppo.com>
>
> vm_map_ram check return value of vb_alloc by IS_ERR. if
> vm_map_ram(page, 0, 0) , vb_alloc(0, GFP_KERNEL) would return NULL
> which cause kernel panic by vmap_pages_range_noflush。fix this by
> return ERR_PTR(-EINVAL) if size is 0.
>
> Signed-off-by: Hailong.Liu <hailong.liu@oppo.com>
> ---
> Changes since v1 [1]:
> - Return ERR_PTR(-EINVAL) or not check IS_ERR_OR_NULL
>
> BTW,  Barry suggests me that if count is 0, return directly, in my
> opinion, change return value is more resonable.
>
> [1] https://lore.kernel.org/all/84d7cd03-1cf8-401a-8edf-2524db0bd6d5@oppo.com/
>
>  mm/vmalloc.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/mm/vmalloc.c b/mm/vmalloc.c
> index a3fedb3ee0db..c430a999805b 100644
> --- a/mm/vmalloc.c
> +++ b/mm/vmalloc.c
> @@ -2173,7 +2173,7 @@ static void *vb_alloc(unsigned long size, gfp_t gfp_mask)
>                  * get_order(0) returns funny result. Just warn and terminate
>                  * early.
>                  */
> -               return NULL;
> +               return ERR_PTR(-EINVAL);

might be ZERO_SIZE_PTR.

>         }
>         order = get_order(size);
>
> --
> 2.34.1


  reply	other threads:[~2024-04-22  3:46 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-19 10:16 hailong.liu
2024-04-22  3:46 ` Barry Song [this message]
2024-04-22 10:38   ` Hailong Liu
2024-04-23  0:52     ` Barry Song
2024-04-22  9:40 ` Uladzislau Rezki

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='CAGsJ_4zUhnAAUb77ktJxDvAQpZhGrs00+8iQU3dhwpy=C_CjDA@mail.gmail.com' \
    --to=21cnbao@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=hailong.liu@oppo.com \
    --cc=hch@infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=lstoakes@gmail.com \
    --cc=urezki@gmail.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