Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp260151ybl; Thu, 29 Aug 2019 22:39:43 -0700 (PDT) X-Google-Smtp-Source: APXvYqx3RAZTYNrrU+KncsG77IAsdFa0EiBt/YhjVrlAmj4nA0bXKQnsEp48MGdr3zhKseEBzIdn X-Received: by 2002:a17:902:e584:: with SMTP id cl4mr13552500plb.160.1567143583021; Thu, 29 Aug 2019 22:39:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1567143583; cv=none; d=google.com; s=arc-20160816; b=x217LQjqe0qZ5u5uOpalYpFcds5FPGPXQ2BxOgE9ZcQ1lQSN5Z0LqeTJLyIP/vOxkc l/Ot5xGsIj+/SXyluBPaWCYjAWaj81bp0P/ehy8heoGYkll3z13PUNkvgrrSB6kRRytm heYuxdEI8tga39q9h6sJYMEq46w2oCNP0hfuKrjX+l2QHDJVvPk1NWmiJsnsZCA8LCYZ VtbYZl2/XWgTgEnGSJIAvdFhFzLS3Ip4POIDlFaUQyGlbrsXUn9aFSxKBxEkJXBir/aP PAIKEbHrwOzBio6bsUkl7qekE6W5V1yAI3gIsDiWHmgMpfsdhw7e26MrSew3AQfVQLG1 mGfA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=hGOk5+30TpPXBAGg/0m+61F5Ok/jXS7mRMJPztkmvV4=; b=Tzp5VXUk3CWCjv1iKnegpfwkOU0EoP7noSp2ysrZRJm40rXiml9GCtPWYcJM483Zc7 ne/vCTOF6NX/tHL+JJtEoR4u664GtfcCCXpuQowO3YNqLLH2P/VGOe0xr2OMTYu4zAMU nGapJcqFfDMcN/XLCVae2GylxeEoQv1UBIKWQ2LdN4LoclWvqtAVDphp9iJ1RFVCFkif fHQvDKkosd8UlcN+ZHxSm8Sphk4NziIkvIPaiRsnc6+Wk800b3iV/7ep9gYZ7kNhwEhm aifwDupKy3+P6xkuPb/tmn0bBgL8Nv6L3yaM8JfU83NOMZ88AxrRb8y0rXnh8xsvv7wg zu9Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t143si3677762pgb.542.2019.08.29.22.39.27; Thu, 29 Aug 2019 22:39:43 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728076AbfH3FiL (ORCPT + 99 others); Fri, 30 Aug 2019 01:38:11 -0400 Received: from mx2.suse.de ([195.135.220.15]:51718 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1725901AbfH3FiL (ORCPT ); Fri, 30 Aug 2019 01:38:11 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id DB987ACA0; Fri, 30 Aug 2019 05:38:09 +0000 (UTC) Date: Fri, 30 Aug 2019 07:38:08 +0200 From: Michal Hocko To: Austin Kim Cc: akpm@linux-foundation.org, urezki@gmail.com, guro@fb.com, rpenyaev@suse.de, rick.p.edgecombe@intel.com, rppt@linux.ibm.com, aryabinin@virtuozzo.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] mm/vmalloc: move 'area->pages' after if statement Message-ID: <20190830053808.GM28313@dhcp22.suse.cz> References: <20190830035716.GA190684@LGEARND20B15> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190830035716.GA190684@LGEARND20B15> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri 30-08-19 12:57:16, Austin Kim wrote: > 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. > > Signed-off-by: Austin Kim Acked-by: Michal Hocko Thanks! > --- > mm/vmalloc.c | 6 ++++-- > 1 file changed, 4 insertions(+), 2 deletions(-) > > diff --git a/mm/vmalloc.c b/mm/vmalloc.c > index b810103..af93ba6 100644 > --- a/mm/vmalloc.c > +++ b/mm/vmalloc.c > @@ -2416,13 +2416,15 @@ 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; > + > for (i = 0; i < area->nr_pages; i++) { > struct page *page; > > -- > 2.6.2 > -- Michal Hocko SUSE Labs