All of lore.kernel.org
 help / color / mirror / Atom feed
From: Lee Jones <lee.jones@linaro.org>
To: stable@vger.kernel.org
Cc: Austin Kim <austindh.kim@gmail.com>,
	Michal Hocko <mhocko@suse.com>,
	Andrew Morton <akpm@linux-foundation.org>,
	Uladzislau Rezki <urezki@gmail.com>, Roman Gushchin <guro@fb.com>,
	Roman Penyaev <rpenyaev@suse.de>,
	Rick Edgecombe <rick.p.edgecombe@intel.com>,
	Mike Rapoport <rppt@linux.ibm.com>,
	Andrey Ryabinin <aryabinin@virtuozzo.com>,
	Linus Torvalds <torvalds@linux-foundation.org>,
	Lee Jones <lee.jones@linaro.org>
Subject: [PATCH 4.19 12/13] mm/vmalloc.c: move 'area->pages' after if statement
Date: Fri,  3 Apr 2020 13:18:58 +0100	[thread overview]
Message-ID: <20200403121859.901838-13-lee.jones@linaro.org> (raw)
In-Reply-To: <20200403121859.901838-1-lee.jones@linaro.org>

From: Austin Kim <austindh.kim@gmail.com>

[ Upstream commit 7ea362427c170061b8822dd41bafaa72b3bcb9ad ]

If !area->pages statement is true where memory allocation fails, area is
freed.

In this case 'area->pages = pages' should not executed.  So move
'area->pages = pages' after if statement.

[akpm@linux-foundation.org: give area->pages the same treatment]
Link: http://lkml.kernel.org/r/20190830035716.GA190684@LGEARND20B15
Signed-off-by: Austin Kim <austindh.kim@gmail.com>
Acked-by: Michal Hocko <mhocko@suse.com>
Reviewed-by: Andrew Morton <akpm@linux-foundation.org>
Cc: Uladzislau Rezki (Sony) <urezki@gmail.com>
Cc: Roman Gushchin <guro@fb.com>
Cc: Roman Penyaev <rpenyaev@suse.de>
Cc: Rick Edgecombe <rick.p.edgecombe@intel.com>
Cc: Mike Rapoport <rppt@linux.ibm.com>
Cc: Andrey Ryabinin <aryabinin@virtuozzo.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Lee Jones <lee.jones@linaro.org>
---
 mm/vmalloc.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/mm/vmalloc.c b/mm/vmalloc.c
index 958d6ba9ee2d1..be65161f97531 100644
--- a/mm/vmalloc.c
+++ b/mm/vmalloc.c
@@ -1668,7 +1668,6 @@ static void *__vmalloc_area_node(struct vm_struct *area, gfp_t gfp_mask,
 	nr_pages = get_vm_area_size(area) >> PAGE_SHIFT;
 	array_size = (nr_pages * sizeof(struct page *));
 
-	area->nr_pages = nr_pages;
 	/* Please note that the recursion is strictly bounded. */
 	if (array_size > PAGE_SIZE) {
 		pages = __vmalloc_node(array_size, 1, nested_gfp|highmem_mask,
@@ -1676,13 +1675,16 @@ static void *__vmalloc_area_node(struct vm_struct *area, gfp_t gfp_mask,
 	} else {
 		pages = kmalloc_node(array_size, nested_gfp, node);
 	}
-	area->pages = pages;
-	if (!area->pages) {
+
+	if (!pages) {
 		remove_vm_area(area->addr);
 		kfree(area);
 		return NULL;
 	}
 
+	area->pages = pages;
+	area->nr_pages = nr_pages;
+
 	for (i = 0; i < area->nr_pages; i++) {
 		struct page *page;
 
-- 
2.25.1


  parent reply	other threads:[~2020-04-03 12:18 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-03 12:18 [PATCH 4.19 00/13] Backported fixes taken from Sony's Vendor tree Lee Jones
2020-04-03 12:18 ` [PATCH 4.19 01/13] clk: qcom: rcg: Return failure for RCG update Lee Jones
2020-04-03 12:18 ` [PATCH 4.19 02/13] drm/msm: stop abusing dma_map/unmap for cache Lee Jones
2020-04-03 12:18 ` [PATCH 4.19 03/13] arm64: Fix size of __early_cpu_boot_status Lee Jones
2020-04-03 12:18 ` [PATCH 4.19 04/13] drm_dp_mst_topology: fix broken drm_dp_sideband_parse_remote_dpcd_read() Lee Jones
2020-04-03 12:18 ` [PATCH 4.19 05/13] wil6210: check rx_buff_mgmt before accessing it Lee Jones
2020-04-03 12:18 ` [PATCH 4.19 06/13] wil6210: ignore HALP ICR if already handled Lee Jones
2020-04-03 12:18 ` [PATCH 4.19 07/13] wil6210: add general initialization/size checks Lee Jones
2020-04-03 12:18 ` [PATCH 4.19 08/13] wil6210: make sure Rx ring sizes are correlated Lee Jones
2020-04-03 12:18 ` [PATCH 4.19 09/13] rpmsg: glink: Remove chunk size word align warning Lee Jones
2020-04-03 12:18 ` [PATCH 4.19 10/13] wil6210: remove reset file from debugfs Lee Jones
2020-04-11 11:47   ` Greg KH
2020-04-14  7:42     ` Lee Jones
2020-04-03 12:18 ` [PATCH 4.19 11/13] perf/core: Reattach a misplaced comment Lee Jones
2020-04-03 12:26   ` Greg KH
2020-04-03 12:52     ` Lee Jones
2020-04-03 13:23       ` Alexander Shishkin
2020-04-11 11:49         ` Greg KH
2020-04-14  7:37           ` Lee Jones
2020-04-03 12:18 ` Lee Jones [this message]
2020-04-03 12:18 ` [PATCH 4.19 13/13] usb: dwc3: don't set gadget->is_otg flag Lee Jones
2020-04-20 11:24 ` [PATCH 4.19 00/13] Backported fixes taken from Sony's Vendor tree Greg KH

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=20200403121859.901838-13-lee.jones@linaro.org \
    --to=lee.jones@linaro.org \
    --cc=akpm@linux-foundation.org \
    --cc=aryabinin@virtuozzo.com \
    --cc=austindh.kim@gmail.com \
    --cc=guro@fb.com \
    --cc=mhocko@suse.com \
    --cc=rick.p.edgecombe@intel.com \
    --cc=rpenyaev@suse.de \
    --cc=rppt@linux.ibm.com \
    --cc=stable@vger.kernel.org \
    --cc=torvalds@linux-foundation.org \
    --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 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.