[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20210329170730.121943-1-colin.king@canonical.com>
Date: Mon, 29 Mar 2021 18:07:30 +0100
From: Colin King <colin.king@...onical.com>
To: Andrew Morton <akpm@...ux-foundation.org>,
Stephen Rothwell <sfr@...b.auug.org.au>,
Nicholas Piggin <npiggin@...il.com>, linux-mm@...ck.org
Cc: kernel-janitors@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: [PATCH][next] mm/vmalloc: Fix read of pointer area after it has been free'd
From: Colin Ian King <colin.king@...onical.com>
Currently the memory pointed to by area is being freed by the
free_vm_area call and then area->nr_pages is referencing the
free'd object. Fix this swapping the order of the warn_alloc
message and the free.
Addresses-Coverity: ("Read from pointer after free")
Fixes: 014ccf9b888d ("mm/vmalloc: improve allocation failure error messages")
Signed-off-by: Colin Ian King <colin.king@...onical.com>
---
mm/vmalloc.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/mm/vmalloc.c b/mm/vmalloc.c
index b73e4e715e0d..7936405749e4 100644
--- a/mm/vmalloc.c
+++ b/mm/vmalloc.c
@@ -2790,11 +2790,11 @@ static void *__vmalloc_area_node(struct vm_struct *area, gfp_t gfp_mask,
}
if (!pages) {
- free_vm_area(area);
warn_alloc(gfp_mask, NULL,
"vmalloc size %lu allocation failure: "
"page array size %lu allocation failed",
area->nr_pages * PAGE_SIZE, array_size);
+ free_vm_area(area);
return NULL;
}
--
2.30.2
Powered by blists - more mailing lists