Received: by 2002:ac0:a591:0:0:0:0:0 with SMTP id m17-v6csp86818imm; Fri, 6 Jul 2018 14:33:30 -0700 (PDT) X-Google-Smtp-Source: AAOMgpff0AMHnXCwVATygbCJD7p9qG1VWY7fvkOQ6TU/yor/ZnvEhyAWFf1BtCg7RZ8SAXgObFM8 X-Received: by 2002:a65:6211:: with SMTP id d17-v6mr10916078pgv.450.1530912810219; Fri, 06 Jul 2018 14:33:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530912810; cv=none; d=google.com; s=arc-20160816; b=jrxkQFb9asWH7A0RdXEjvq9h4exjNsS0KDRryoNCBuaz9prGjun1fd50w9y+9suG5S CHYr3QpJKXZwlXZJS3YX/VlZd6NlsJ4kd+7c7bfHghb8SYc9cu0DLXHgBAGJXyxc2zAy C0YnERdwcSay2cqeMzR+gWGBZt890FkUTttOeI4PAUePt9YhX9M8nPqvLxFxq0NcQNzT xMGFQdt7bOaOzv2Dq0hJrH0OpKooOj0g2Z2Wipiy/95E3vVQul2BpYri69NHF83zdA4g Z2fzwvhQGqqMJS7Ko2ED3XWSmWmmJm6uoZH5G0EthDeMFeflYYh6kf0yIaFc979gBJru QjNg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date :arc-authentication-results; bh=p/ctYS5IeHz2fi4aGtoYQwef4AWJYDSRMepmavlY1TM=; b=esZn7nVYf2wEYz9hZYOAibsI5DQHKoU3ossqnEJshhpk9gQ0i5CHkHbnOlUwBmcP1f ZM41Z2d+mU3j8dlhQNRbh94BIzZVTxgHz0ehJ71GEyjyMEhwI44UDSxifXzJx/7CiuN0 sG64Vq1zYMA0rPinvrrn0m3mI63EbDejKNQHpyQp15+sB2Mt5jjVfAEOlDsmCv0ND5EU Di56R2lJEr3vuXBQJpDrmOUFIsfQfKsSy9vbSgxiPRoII5C2CGBm+j5B2FUJyeMnyXpO lqD3+1M5qTfR463DDNgkIQD8tcwSYvd4TIPikXGUpv4Zc6PdZazJxWI1YCRRB69f4cMG eUuw== 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 20-v6si9849692pfr.242.2018.07.06.14.33.15; Fri, 06 Jul 2018 14:33:30 -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 S1753791AbeGFVc2 (ORCPT + 99 others); Fri, 6 Jul 2018 17:32:28 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:50590 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753672AbeGFVc1 (ORCPT ); Fri, 6 Jul 2018 17:32:27 -0400 Received: from akpm3.svl.corp.google.com (unknown [104.133.9.92]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 95888BC6; Fri, 6 Jul 2018 21:32:26 +0000 (UTC) Date: Fri, 6 Jul 2018 14:32:25 -0700 From: Andrew Morton To: Ross Zwisler Cc: pasha.tatashin@oracle.com, linux-nvdimm@lists.01.org, osalvador@techadventures.net, bhe@redhat.com, Dave Hansen , LKML , Linux MM , Michal Hocko , Vlastimil Babka , "Kirill A. Shutemov" , osalvador@suse.de Subject: Re: [PATCH] mm/sparse.c: fix error path in sparse_add_one_section Message-Id: <20180706143225.1cf9569f240dccf91bdc3788@linux-foundation.org> In-Reply-To: <20180706190658.6873-1-ross.zwisler@linux.intel.com> References: <20180706190658.6873-1-ross.zwisler@linux.intel.com> X-Mailer: Sylpheed 3.6.0 (GTK+ 2.24.31; x86_64-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, 6 Jul 2018 13:06:58 -0600 Ross Zwisler wrote: > 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. > > With the above referenced commit, though, an -EEXIST error return from > sparse_index_init() now takes us through the function and into the error > case after 'out:'. This eventually causes a kernel BUG, probably because > we've just freed a memory section that we successfully set up and marked as > present: Thanks. And gee it would be nice if some of this code was commented. I *assume* what's happening with that -EEXIST is that sparse_add_one_section() is discovering that the root mem_section was already initialized so things are OK. Maybe. My mind-reading skills aren't so good on Fridays. And sparse_index_init() sure looks like it needs locking to avoid races around mem_section[root]. Or perhaps we're known to be single-threaded here.