Received: by 2002:ac0:a591:0:0:0:0:0 with SMTP id m17-v6csp80186imm; Fri, 6 Jul 2018 14:24:37 -0700 (PDT) X-Google-Smtp-Source: AAOMgpdDxiGj1qf2Y2yaMBl0+2RGPwNsd3SmVRTC57+gzu0Zk2kpPRtkfms7ZQiAAkxjWc57BEJP X-Received: by 2002:a17:902:7d82:: with SMTP id a2-v6mr11696476plm.202.1530912277510; Fri, 06 Jul 2018 14:24:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530912277; cv=none; d=google.com; s=arc-20160816; b=Vw7w0RQKzeDmc8eBvMjszsqjnj1Mh4z4pnjBI0ahlV6ZAKl7omPy8enMV20wDVB2co YTYYt0YZnA1hV7zaIE9klBLhI1E5kkbmuAK2ityJFAxJD8aWHxC8D92hcKLoUB9VF5rM xkUI/HpOfSM7HljHmch3vpg5sk5Cg2vCBD72sIEPgQj7DLUzJBe3S1F84hiX4dkxQJUG yrD8NKY5iENX7ERlah2PktR0JwHLnKPUg8yctJSt7VDVYamsIaHoxF3nrSjSCZnVyhzV o5urVIjf1dMc9ycK3fEE69f7XG29C4tcI2NNyHyxVEWp1itbc64OsTPcnh7w8R5ViOUd RGLw== 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:arc-authentication-results; bh=thi0DSX2sAOi0pFHz7c9yxGly7b6YkqtJDRpM9XbMx4=; b=PXfWUEN32JtWxmk+SDmEx9+zZd+j89G1NzsbiJOnSF4bwVOz8Tl3biNQCiIF1JYPMH SopjeR0K88JDvXA0y2cpHeaDsQJNqF1GtvrSOLozhbC5IxQ2+H8JbRJlu5LT0Xe1ELIw 0fx31IBb1Fwfs5teEYSigzR4LU3wb/rkxGH4HOJ8pbNek0WuuHHLw+PIgRyLB/o3SglY zrQaEqfSiF+DPUiC9ZMuIZdhRgg1F6ypIT6C7VWMPt8PhnSHWtXw4pAKuVFFdkYkQutI ae8GuWRcGSoKPT6kHC6ghZBGjP/GuPhmfEueLovA0Y4exQfP0Mxx1L/ObJPXKIUDTIr9 TDNA== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g18-v6si8411756pgd.137.2018.07.06.14.24.21; Fri, 06 Jul 2018 14:24:37 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932754AbeGFVXb (ORCPT + 99 others); Fri, 6 Jul 2018 17:23:31 -0400 Received: from mail-wr1-f65.google.com ([209.85.221.65]:45561 "EHLO mail-wr1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932336AbeGFVXa (ORCPT ); Fri, 6 Jul 2018 17:23:30 -0400 Received: by mail-wr1-f65.google.com with SMTP id u7-v6so5361632wrn.12 for ; Fri, 06 Jul 2018 14:23:29 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=thi0DSX2sAOi0pFHz7c9yxGly7b6YkqtJDRpM9XbMx4=; b=EQHBmQyL+hnYFbschCe3zVsc/P/O8T0hVCGQLA+sfoWEdG/cNPhhfKDJV4CuGkTrmL vVES9hX8ThuroPjT3zuuT7xyDDyn82AA8ptNOSZbTAn8Pp9fe33S+l1hUoRnaKdDZrmV bcxR9RJRHzW4EUNYkG2ipiPvvMAO2DdwnTch4YdBkFw1ySg3BcjNPUjJo4fcjv8QeD43 oWMtQXKUS7/CxyFuNRTyfji79hmKvn6fC3hZwFGh+Yr3jTnaGygQGFf7SHaHXbGgd1EX LQs7ZLhcA2E9qAR8atP03ApAx83wHLqktdptk7AavDdOTnKWWsfWHBM0SxihGt1KRtWf t+Hg== X-Gm-Message-State: APt69E2e0YpMoDAGEeXoFnGL5UNggkVTm3iJOj3KV5tUR4ZZBe762R03 opro+OpwJpkOsatV+JT5G08= X-Received: by 2002:adf:af45:: with SMTP id z63-v6mr8260090wrc.238.1530912209268; Fri, 06 Jul 2018 14:23:29 -0700 (PDT) Received: from techadventures.net (techadventures.net. [62.201.165.239]) by smtp.gmail.com with ESMTPSA id p4-v6sm9177143wrj.71.2018.07.06.14.23.28 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 06 Jul 2018 14:23:28 -0700 (PDT) Received: by techadventures.net (Postfix, from userid 1000) id B1966123C48; Fri, 6 Jul 2018 23:23:27 +0200 (CEST) Date: Fri, 6 Jul 2018 23:23:27 +0200 From: Oscar Salvador To: Ross Zwisler Cc: pasha.tatashin@oracle.com, linux-nvdimm@lists.01.org, bhe@redhat.com, Dave Hansen , LKML , Linux MM , Michal Hocko , Vlastimil Babka , Andrew Morton , "Kirill A. Shutemov" , osalvador@suse.de Subject: Re: [PATCH] mm/sparse.c: fix error path in sparse_add_one_section Message-ID: <20180706212327.GA10824@techadventures.net> References: <20180706190658.6873-1-ross.zwisler@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180706190658.6873-1-ross.zwisler@linux.intel.com> User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Jul 06, 2018 at 01:06:58PM -0600, Ross Zwisler wrote: > The following commit in -next: > > commit 054620849110 ("mm/sparse.c: make sparse_init_one_section void and > remove check") > > changed how the error handling in sparse_add_one_section() works. > > Previously sparse_index_init() could return -EEXIST, and the function would > continue on happily. 'ret' would get unconditionally overwritten by the > result from sparse_init_one_section() and the error code after the 'out:' > label wouldn't be triggered. My bad, I missed that. > diff --git a/mm/sparse.c b/mm/sparse.c > index 9574113fc745..d254bd2d3289 100644 > --- a/mm/sparse.c > +++ b/mm/sparse.c > @@ -753,8 +753,12 @@ int __meminit sparse_add_one_section(struct pglist_data *pgdat, > * plus, it does a kmalloc > */ > ret = sparse_index_init(section_nr, pgdat->node_id); > - if (ret < 0 && ret != -EEXIST) > - return ret; > + if (ret < 0) { > + if (ret == -EEXIST) > + ret = 0; > + else > + return ret; > + } sparse_index_init() can return: -ENOMEM, -EEXIST or 0. So what about this?: diff --git a/mm/sparse.c b/mm/sparse.c index f55e79fda03e..eb188eb6b82d 100644 --- a/mm/sparse.c +++ b/mm/sparse.c @@ -770,6 +770,7 @@ int __meminit sparse_add_one_section(struct pglist_data *pgdat, ret = sparse_index_init(section_nr, pgdat->node_id); if (ret < 0 && ret != -EEXIST) return ret; + ret = 0; Does this look more clean? -- Oscar Salvador SUSE L3