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.14 24/24] mm/vmalloc.c: move 'area->pages' after if statement
Date: Tue, 21 Apr 2020 13:40:17 +0100	[thread overview]
Message-ID: <20200421124017.272694-25-lee.jones@linaro.org> (raw)
In-Reply-To: <20200421124017.272694-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 d00961ba0c42d..88091fd704f42 100644
--- a/mm/vmalloc.c
+++ b/mm/vmalloc.c
@@ -1682,7 +1682,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,
@@ -1690,13 +1689,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-21 12:41 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-21 12:39 [PATCH 4.14 00/24] Backported fixes taken from Sony's Vendor tree Lee Jones
2020-04-21 12:39 ` [PATCH 4.14 01/24] drm: NULL pointer dereference [null-pointer-deref] (CWE 476) problem Lee Jones
2020-04-21 12:39 ` [PATCH 4.14 02/24] clk: Fix debugfs_create_*() usage Lee Jones
2020-04-21 12:39 ` [PATCH 4.14 03/24] Revert "gpio: set up initial state from .get_direction()" Lee Jones
2020-04-21 12:39 ` [PATCH 4.14 04/24] arm64: perf: remove unsupported events for Cortex-A73 Lee Jones
2020-04-21 12:39 ` [PATCH 4.14 05/24] arm64: traps: Don't print stack or raw PC/LR values in backtraces Lee Jones
2020-04-21 12:39 ` [PATCH 4.14 06/24] android: binder: Use true and false for boolean values Lee Jones
2020-04-21 17:39   ` Greg Kroah-Hartman
2020-04-21 12:40 ` [PATCH 4.14 07/24] arch_topology: Fix section miss match warning due to free_raw_capacity() Lee Jones
2020-04-21 12:40 ` [PATCH 4.14 08/24] wil6210: increase firmware ready timeout Lee Jones
2020-04-21 12:40 ` [PATCH 4.14 09/24] wil6210: fix temperature debugfs Lee Jones
2020-04-21 12:40 ` [PATCH 4.14 10/24] scsi: ufs: make sure all interrupts are processed Lee Jones
2020-04-21 12:40 ` [PATCH 4.14 11/24] scsi: ufs: ufs-qcom: remove broken hci version quirk Lee Jones
2020-04-21 12:40 ` [PATCH 4.14 12/24] wil6210: rate limit wil_rx_refill error Lee Jones
2020-04-21 12:40 ` [PATCH 4.14 13/24] rpmsg: glink: use put_device() if device_register fail Lee Jones
2020-04-21 12:40 ` [PATCH 4.14 14/24] rtc: pm8xxx: Fix issue in RTC write path Lee Jones
2020-04-21 12:40 ` [PATCH 4.14 15/24] net: qualcomm: rmnet: Fix casting issues Lee Jones
2020-04-21 17:41   ` Greg KH
2020-04-21 12:40 ` [PATCH 4.14 16/24] rpmsg: glink: Fix missing mutex_init() in qcom_glink_alloc_channel() Lee Jones
2020-04-21 12:40 ` [PATCH 4.14 17/24] rpmsg: glink: smem: Ensure ordering during tx Lee Jones
2020-04-21 12:40 ` [PATCH 4.14 18/24] wil6210: fix PCIe bus mastering in case of interface down Lee Jones
2020-04-21 12:40 ` [PATCH 4.14 19/24] wil6210: add block size checks during FW load Lee Jones
2020-04-21 12:40 ` [PATCH 4.14 20/24] wil6210: fix length check in __wmi_send Lee Jones
2020-04-21 12:40 ` [PATCH 4.14 21/24] wil6210: abort properly in cfg suspend Lee Jones
2020-04-21 12:40 ` [PATCH 4.14 22/24] soc: qcom: smem: Use le32_to_cpu for comparison Lee Jones
2020-04-21 12:40 ` [PATCH 4.14 23/24] of: fix missing kobject init for !SYSFS && OF_DYNAMIC config Lee Jones
2020-04-21 12:40 ` Lee Jones [this message]
2020-04-21 17:58 ` [PATCH 4.14 00/24] 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=20200421124017.272694-25-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.