[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAGsJ_4w+L03rPcFbLm4E5sWixkKLizB4vxR-Z6LHbqwV56vB4w@mail.gmail.com>
Date: Wed, 28 Feb 2024 22:39:41 +1300
From: Barry Song <21cnbao@...il.com>
To: 刘海龙(LaoLiu) <liuhailong@...o.com>
Cc: "akpm@...ux-foundation.org" <akpm@...ux-foundation.org>, "urezki@...il.com" <urezki@...il.com>,
"hch@...radead.org" <hch@...radead.org>, "lstoakes@...il.com" <lstoakes@...il.com>,
"linux-mm@...ck.org" <linux-mm@...ck.org>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH] mm/vmalloc: Fix return value check for vb_alloc
On Wed, Feb 28, 2024 at 10:34 PM Barry Song <21cnbao@...il.com> wrote:
>
> On Wed, Feb 28, 2024 at 9:51 PM 刘海龙(LaoLiu) <liuhailong@...o.com> wrote:
> >
> > If vm_map_ram(page, 0, 0) would cause panic by vmap_pages_range_noflush, so
> > change IS_ERR to IS_ERR_OR_NULL to fix this.
> >
> > Signed-off-by: Hailong.Liu <liuhailong@...o.com>
> > ---
> > mm/vmalloc.c | 2 +-
> > 1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/mm/vmalloc.c b/mm/vmalloc.c
> > index d12a17fc0c17..109732006cf7 100644
> > --- a/mm/vmalloc.c
> > +++ b/mm/vmalloc.c
> > @@ -2387,7 +2387,7 @@ void *vm_map_ram(struct page **pages, unsigned int
> > count, int node)
> >
> > if (likely(count <= VMAP_MAX_ALLOC)) {
> > mem = vb_alloc(size, GFP_KERNEL);
> > - if (IS_ERR(mem))
> > + if (IS_ERR_OR_NULL(mem))
>
> it seems the only case for vb_alloc to return NULL is size = 0, isn't
> it a bug of
> caller?
what about the below?
diff --git a/mm/vmalloc.c b/mm/vmalloc.c
index 25a8df497255..640157221c95 100644
--- a/mm/vmalloc.c
+++ b/mm/vmalloc.c
@@ -2834,6 +2834,9 @@ void *vm_map_ram(struct page **pages, unsigned
int count, int node)
unsigned long addr;
void *mem;
+ if (unlikely(count == 0))
+ return NULL;
+
if (likely(count <= VMAP_MAX_ALLOC)) {
mem = vb_alloc(size, GFP_KERNEL);
if (IS_ERR(mem))
>
> > return NULL;
> > addr = (unsigned long)mem;
> > } else {
> > --
> > 2.34.1
Thanks
Barry
Powered by blists - more mailing lists