Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3431313imu; Sun, 11 Nov 2018 14:58:14 -0800 (PST) X-Google-Smtp-Source: AJdET5dNmPSLltE/7pzr/hj7MWWHS0T9o/4fmQonipcGshorrFzfQWhSYoWZAYa53/4irB3Qrd9C X-Received: by 2002:a63:ee0e:: with SMTP id e14mr14982680pgi.8.1541977094264; Sun, 11 Nov 2018 14:58:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541977094; cv=none; d=google.com; s=arc-20160816; b=X8qahv7HXPnmnoH3e9BOoIIhmfoUtwZo+AX/Nd40EHmPoNsUY1EL5hEqIo7+5uO5Gt D67kLo65re9LkeRYn9VCgUuYant65Y6Qd/bt0aOw5uuBpqbYnPRlaa3lz/jnPpRVbZb5 KFAtx7SKWrT8xFBxN3QVc6M+w4l1OgIEpUn1OHCLuKxF0gxJpN01fk07phY5IFvZ7XCE jgEmdpUObvT31fj7XnmX6qtut1DV84aXXQ4dKaLWyOIT3TGeGm3/GjD+njRO/EU4RcVI ouCStEpdu2Ea+N5qBaLr2w9+gbyg+ityeeuBHYa+g9gV+v3cdakeTacBglQ7qS5ayDy/ 5wsQ== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=N5lo4zRkPXW8hsQrcCQwrNCiAA2It83yNDFKK2oUJaw=; b=DudNoOp5LKPzZY9AcG47Jqz956VB4fqsVZ/89qWr97AsfdqpbupC6SeyjOBwkNoMHZ /2z647CaqZPQb2DzzLss+tDBKmwtvrT0OoFpIWA+yalt7t5QlOeeCIL8A7VxZGOpWf3t D9EdtVUSKFNwXzsyb0seoFQhIayrLo191MjdD0pTI2xMamvqoZ/wf1AEJsdBJ686FLaq uBfVi5Agt7S5KUibtjqICyAOO3XXXfist+DZi2Ub2W0ydeqsAe3E4aAwhEyhNhGi2D/O iyNpa2GMrfvBywHRA6bKcYcRaAf67SUbnKkunzu7Tj9k8szbJp1U0Kp9fla+tgNaF3cx j5nA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=bRdI4m1N; 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 t10si15226869pgn.551.2018.11.11.14.57.59; Sun, 11 Nov 2018 14:58:14 -0800 (PST) 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; dkim=pass header.i=@kernel.org header.s=default header.b=bRdI4m1N; 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 S2403823AbeKLIWp (ORCPT + 99 others); Mon, 12 Nov 2018 03:22:45 -0500 Received: from mail.kernel.org ([198.145.29.99]:54092 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390677AbeKLIWl (ORCPT ); Mon, 12 Nov 2018 03:22:41 -0500 Received: from localhost (unknown [206.108.79.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 6B58B223C8; Sun, 11 Nov 2018 22:32:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1541975564; bh=iYS39zyXV/xZ8hLQUWEvOmRMnsaBOmzs3HxmWRQYxcI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=bRdI4m1NJsmJ3ZnF5s1bsBENIUxUnVcq+bsz/1SHE4JVBJKqVEIRvskrDBzhvV5N1 MZEwg8WdTs0NdSgl/TQ9x0Wod2EUFfxIJQuRbXMcxRQqB62/haIXuCuiu1cbB2VKbL Gvlfe06x59avLsV9FfWnLdBzvLk67WikfYA4WznM= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Johannes Thumshirn , Dave Jiang , Dan Williams Subject: [PATCH 4.14 132/222] libnvdimm, region: Fail badblocks listing for inactive regions Date: Sun, 11 Nov 2018 14:23:49 -0800 Message-Id: <20181111221659.405897588@linuxfoundation.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181111221647.665769131@linuxfoundation.org> References: <20181111221647.665769131@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.14-stable review patch. If anyone has any objections, please let me know. ------------------ From: Dan Williams commit 5d394eee2c102453278d81d9a7cf94c80253486a upstream. While experimenting with region driver loading the following backtrace was triggered: INFO: trying to register non-static key. the code is fine but needs lockdep annotation. turning off the locking correctness validator. [..] Call Trace: dump_stack+0x85/0xcb register_lock_class+0x571/0x580 ? __lock_acquire+0x2ba/0x1310 ? kernfs_seq_start+0x2a/0x80 __lock_acquire+0xd4/0x1310 ? dev_attr_show+0x1c/0x50 ? __lock_acquire+0x2ba/0x1310 ? kernfs_seq_start+0x2a/0x80 ? lock_acquire+0x9e/0x1a0 lock_acquire+0x9e/0x1a0 ? dev_attr_show+0x1c/0x50 badblocks_show+0x70/0x190 ? dev_attr_show+0x1c/0x50 dev_attr_show+0x1c/0x50 This results from a missing successful call to devm_init_badblocks() from nd_region_probe(). Block attempts to show badblocks while the region is not enabled. Fixes: 6a6bef90425e ("libnvdimm: add mechanism to publish badblocks...") Cc: Reviewed-by: Johannes Thumshirn Reviewed-by: Dave Jiang Signed-off-by: Dan Williams Signed-off-by: Greg Kroah-Hartman --- drivers/nvdimm/region_devs.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) --- a/drivers/nvdimm/region_devs.c +++ b/drivers/nvdimm/region_devs.c @@ -513,10 +513,17 @@ static ssize_t region_badblocks_show(str struct device_attribute *attr, char *buf) { struct nd_region *nd_region = to_nd_region(dev); + ssize_t rc; - return badblocks_show(&nd_region->bb, buf, 0); -} + device_lock(dev); + if (dev->driver) + rc = badblocks_show(&nd_region->bb, buf, 0); + else + rc = -ENXIO; + device_unlock(dev); + return rc; +} static DEVICE_ATTR(badblocks, 0444, region_badblocks_show, NULL); static ssize_t resource_show(struct device *dev,