Received: by 10.213.65.68 with SMTP id h4csp276467imn; Fri, 23 Mar 2018 04:32:20 -0700 (PDT) X-Google-Smtp-Source: AG47ELvRMNbnNCUsfg3WClBg9j9vWuaLZ+ToxBTeW4bvctb1VjfMANglCcCxIDZhlrVx0ZEvWDX9 X-Received: by 10.99.100.6 with SMTP id y6mr20658638pgb.254.1521804740004; Fri, 23 Mar 2018 04:32:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521804739; cv=none; d=google.com; s=arc-20160816; b=JKbyBkWd4VvDvwYJ8rpmGQQbrMwNMN21Qcw7Yv9NgOzSeJfMYirnQZFLCYzc2fRb7b zzXytfUjFSnWXM+mEkygF0QXZcIyvhuHLLOBoBsKpFpz58+XmfL+vcetjUik0qT7/4SO huQX+FGJpz78Pa5DkoTRfvtYx/NUeB51R+omZcLLf10yzpWqZzuh3aZgvn4jP3fYHRw9 rof8ImpIfrIrucbIa0DdNUucwzhTvk066e+Rga3P7uoJvuhkbo5Y5UgM0L6Bs1XCJvjL F2MUpjYd5vbr7/mQBYQ5jaCwd6oZMV0Vlnw91eGt+gMlIi2LXB44OyvaHTJOkW6OFTyr QOOA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=cYBwezKud9zygmpTuOUgvc6X9J13vMDsEKgwXasG5FY=; b=B4MSLVOJ0x5mMj6npl2IhhYIUS/5Td67JxHTbImwZtJ6UWp+J487i+7qjkrHXxvgvy 29MeQq3suQ4csvsX7VohWf/pqBMZd/BGiTVf7LlzM1GOjkTc8vXjJU+T5AtI6A4R8XK0 TKsqOaOQyiJfSUK953BeTxTUZr0yECHolc6SVY/RrRwsuPQ5tH9cY/Z+tt+cZvyqbWOo UgOrW5n1nbh8roqg+P/PHl6BUnbU/Dhz5lp+bDKvfXyuNpn8H0wz/S0Os/uWQr8+kVLW oZX0BTcMYr+R2TvYep/abrRRvptLt13Jyp5gsZnVrAa39PgrtOf9Aa8Zj/meka7iVKDz 1gGA== 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 d16-v6si7973325pll.504.2018.03.23.04.32.05; Fri, 23 Mar 2018 04:32:19 -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 S1755167AbeCWKGI (ORCPT + 99 others); Fri, 23 Mar 2018 06:06:08 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:40648 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755155AbeCWKGE (ORCPT ); Fri, 23 Mar 2018 06:06:04 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id D4A3729; Fri, 23 Mar 2018 10:06:03 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Linda Knippers , Dan Williams , Sasha Levin Subject: [PATCH 4.9 025/177] tools/testing/nvdimm: fix nfit_test shutdown crash Date: Fri, 23 Mar 2018 10:52:33 +0100 Message-Id: <20180323094206.300215312@linuxfoundation.org> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180323094205.090519271@linuxfoundation.org> References: <20180323094205.090519271@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.9-stable review patch. If anyone has any objections, please let me know. ------------------ From: Dan Williams [ Upstream commit 8b06b884cd98f7ec8b5028680b99fabfb7b3e192 ] Keep the nfit_test instances alive until after nfit_test_teardown(), as we may be doing resource lookups until the final un-registrations have completed. This fixes crashes of the form. BUG: unable to handle kernel NULL pointer dereference at 0000000000000038 IP: __release_resource+0x12/0x90 Call Trace: remove_resource+0x23/0x40 __wrap_remove_resource+0x29/0x30 [nfit_test_iomap] acpi_nfit_remove_resource+0xe/0x10 [nfit] devm_action_release+0xf/0x20 release_nodes+0x16d/0x2b0 devres_release_all+0x3c/0x60 device_release+0x21/0x90 kobject_release+0x6a/0x170 kobject_put+0x2f/0x60 put_device+0x17/0x20 platform_device_unregister+0x20/0x30 nfit_test_exit+0x36/0x960 [nfit_test] Reported-by: Linda Knippers Signed-off-by: Dan Williams Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- tools/testing/nvdimm/test/nfit.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) --- a/tools/testing/nvdimm/test/nfit.c +++ b/tools/testing/nvdimm/test/nfit.c @@ -1908,6 +1908,7 @@ static __init int nfit_test_init(void) put_device(&pdev->dev); goto err_register; } + get_device(&pdev->dev); rc = dma_coerce_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(64)); if (rc) @@ -1926,6 +1927,10 @@ static __init int nfit_test_init(void) if (instances[i]) platform_device_unregister(&instances[i]->pdev); nfit_test_teardown(); + for (i = 0; i < NUM_NFITS; i++) + if (instances[i]) + put_device(&instances[i]->pdev.dev); + return rc; } @@ -1933,10 +1938,13 @@ static __exit void nfit_test_exit(void) { int i; - platform_driver_unregister(&nfit_test_driver); for (i = 0; i < NUM_NFITS; i++) platform_device_unregister(&instances[i]->pdev); + platform_driver_unregister(&nfit_test_driver); nfit_test_teardown(); + + for (i = 0; i < NUM_NFITS; i++) + put_device(&instances[i]->pdev.dev); class_destroy(nfit_test_dimm); }