All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH][next] mm/vmalloc: Fix read of pointer area after it has been free'd
@ 2021-03-29 17:07 Colin King
  2021-03-29 17:14 ` Matthew Wilcox
  0 siblings, 1 reply; 7+ messages in thread
From: Colin King @ 2021-03-29 17:07 UTC (permalink / raw)
  To: Andrew Morton, Stephen Rothwell, Nicholas Piggin, linux-mm
  Cc: kernel-janitors, linux-kernel

From: Colin Ian King <colin.king@canonical.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@canonical.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


^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2021-03-30  9:54 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-29 17:07 [PATCH][next] mm/vmalloc: Fix read of pointer area after it has been free'd Colin King
2021-03-29 17:14 ` Matthew Wilcox
2021-03-29 17:40   ` Uladzislau Rezki
2021-03-29 18:14     ` Uladzislau Rezki
2021-03-29 18:30       ` Uladzislau Rezki
2021-03-29 19:32         ` Uladzislau Rezki
2021-03-30  9:52   ` Dan Carpenter

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.