Received: by 2002:ac0:a591:0:0:0:0:0 with SMTP id m17-v6csp387938imm; Fri, 6 Jul 2018 23:02:55 -0700 (PDT) X-Google-Smtp-Source: AAOMgpdx8vE8abx/7eFBdeQSiEvjyXXNC1JZNp5JblR+p6yKkT7P5JkseI6sbDV2MR8V7xMKme6J X-Received: by 2002:a17:902:6047:: with SMTP id a7-v6mr12660989plt.188.1530943375353; Fri, 06 Jul 2018 23:02:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530943375; cv=none; d=google.com; s=arc-20160816; b=jTucgrxOJyo77Prr2KGJ/Rfx1Uu62nyAAtdMFc2fmiugcepQQbsLO0SMXGutg2BVVn 43bQiC7+LfnkO+S1ssxvK+tiF5zuwua9r6XwYqfLKTU2IiPJTCxi5qJku3ma2U50N0Rf T5Gb4fT7/FAH2LvL5iSpTNMVhSqKib+MVnYmrqTDZ0Ua51vPq5F5vKKhEDs62eOIA1s/ 5Lm5Pzlqord5nVv9UH08jKXmrDy7dTekOQl6ihCoB1Q3xNLei4NHebvFHIOq1KDsmhSG VhO1KeRTkbaTYDlhc50tlcaBBWE+D1JJfMPpfQfqTuFhkmtDPAiLBqyvlH8TDPUwvMDv hhDQ== 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=zC7V3Sp6DQW9aUfDnOJxaKZIQhOmT3snXeuCyiYxGC8=; b=lqp0nH+EQxk3R2mIg3ZS4Q2ZjK2+xtm8M8VhYH44FZkC9rJqehUEJ0Iag88PSXTI5e Ryt7E8AcmTValU5kajKgt82ZPfG5jojWUjs8J13JRJNy9iH0aN29AQA7tc/whM4VPwLN PtFE07R1Bi18FoSR1PuPYY8IAhP0s7JZqW8Na/RenoyPlVBsFo38x3Afv47qDTnzGPLH WBfehuhp0A9w5iYEoevoDMh6KgoqXlD2V9d5KA+7qcOFFsWcEjAkmwFAE3JV5z6UrDK1 r5CGka4JL58qkRur/Mn24t7xSQ9O+Q8UiDPCvvtYdmrXmJcM9MXbpOQmwTyB1XvSYZEH zTEg== 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 k6-v6si9717265pla.78.2018.07.06.23.02.38; Fri, 06 Jul 2018 23:02:55 -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 S1750989AbeGGGB6 (ORCPT + 99 others); Sat, 7 Jul 2018 02:01:58 -0400 Received: from mail-wr1-f67.google.com ([209.85.221.67]:46318 "EHLO mail-wr1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750816AbeGGGB5 (ORCPT ); Sat, 7 Jul 2018 02:01:57 -0400 Received: by mail-wr1-f67.google.com with SMTP id s11-v6so5946230wra.13 for ; Fri, 06 Jul 2018 23:01:56 -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=zC7V3Sp6DQW9aUfDnOJxaKZIQhOmT3snXeuCyiYxGC8=; b=KV2l2cBmnATKwAGLs5OHjzqPye1Smb3aK1j6xLhljWel54exoAa7igtGrPYBGr5JGl 7yU0wCZwS2ewIFcXe1nXcx+9B+ghkdFaJaC80h8XqHlphm3R6H1kgocFUAFWAOhEK1ZE Hwcp8YUtoHr6pahjCrlu6T3NF9EpLf0ufM2SozX1K+td/OsKCIV11KQvY04wZHOEfbuu 7OzydGtpi/B0EpIqczGyrFPpMkkMZfN4lqQ6q6d6sMxhxB/0XdAd+T7TzBkH5CBofn8h DTbWNo+5ROdtG1PniL/dWy37dMnEUUK6bZNS/HZ8TjzBh0aoNJaeNS500DZuoJa6oNP0 t3YA== X-Gm-Message-State: APt69E3ZRrSU26ZBsoN7NLSGUxQPUC32R0w0vZPyNSht/MF+LAOVcL6h SEl4UnYaIlZ8+6WrCng1QL0= X-Received: by 2002:a5d:4cc5:: with SMTP id c5-v6mr7099666wrt.210.1530943316218; Fri, 06 Jul 2018 23:01:56 -0700 (PDT) Received: from techadventures.net (techadventures.net. [62.201.165.239]) by smtp.gmail.com with ESMTPSA id 56-v6sm5566876wry.52.2018.07.06.23.01.54 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 06 Jul 2018 23:01:55 -0700 (PDT) Received: by techadventures.net (Postfix, from userid 1000) id 03EB5123C67; Sat, 7 Jul 2018 08:01:53 +0200 (CEST) Date: Sat, 7 Jul 2018 08:01:53 +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 v2] mm/sparse.c: fix error path in sparse_add_one_section Message-ID: <20180707060153.GA13141@techadventures.net> References: <20180706190658.6873-1-ross.zwisler@linux.intel.com> <20180706223358.742-1-ross.zwisler@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180706223358.742-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 04:33: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. > > 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: > > BUG: unable to handle kernel paging request at ffffea0005000080 > RIP: 0010:memmap_init_zone+0x154/0x1cf > > Call Trace: > move_pfn_range_to_zone+0x168/0x180 > devm_memremap_pages+0x29b/0x480 > pmem_attach_disk+0x1ae/0x6c0 [nd_pmem] > ? devm_memremap+0x79/0xb0 > nd_pmem_probe+0x7e/0xa0 [nd_pmem] > nvdimm_bus_probe+0x6e/0x160 [libnvdimm] > driver_probe_device+0x310/0x480 > __device_attach_driver+0x86/0x100 > ? __driver_attach+0x110/0x110 > bus_for_each_drv+0x6e/0xb0 > __device_attach+0xe2/0x160 > device_initial_probe+0x13/0x20 > bus_probe_device+0xa6/0xc0 > device_add+0x41b/0x660 > ? lock_acquire+0xa3/0x210 > nd_async_device_register+0x12/0x40 [libnvdimm] > async_run_entry_fn+0x3e/0x170 > process_one_work+0x230/0x680 > worker_thread+0x3f/0x3b0 > kthread+0x12f/0x150 > ? process_one_work+0x680/0x680 > ? kthread_create_worker_on_cpu+0x70/0x70 > ret_from_fork+0x3a/0x50 > > Fix this by clearing 'ret' back to 0 if sparse_index_init() returns > -EEXIST. This restores the previous behavior. > > Signed-off-by: Ross Zwisler Reviewed-by: Oscar Salvador -- Oscar Salvador SUSE L3