Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp1067785imm; Fri, 28 Sep 2018 11:20:26 -0700 (PDT) X-Google-Smtp-Source: ACcGV610hs9eRKfqnAl+yxpQN9Tj0SgICk7/cHkmMjnIlAw0EfA/65zuQ3SB9gsb8UqPsD5afkCE X-Received: by 2002:a63:2d43:: with SMTP id t64-v6mr4132969pgt.128.1538158826318; Fri, 28 Sep 2018 11:20:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1538158826; cv=none; d=google.com; s=arc-20160816; b=I4aQyWAAp+P8NihzlDKGtZtgiQ9RyoKocyzrzoWUvp1vitKJJDDJTe2EE4vVKsAhrn cpL+pk9Bv2XxTU3MyzVEK37uxaaB31ZM/qE+LClIN59IlwbqORnVm6FPcawU4w7IaEA0 M8QoULKRpPwrIOXJVZ86jGp6YfrAm17lQ5piljHybJdUQyNFkpLCMA2R/DLwy0hxzXUr ovN691+Hzj9XbpnfUgEdm/FdI0P6AOAA2GQl1Joq6NyBbSoNW+SJ+R2wg9ZOPeV2qlD3 maZjYBtrRBU1XNRzkRExcMMNW5sbSklqMc8ophJhHRw9SHbsI9Ajn1OqmyctQ1gz8q7H Hzpg== 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:message-id:date:cc:to:from:subject; bh=IKscOR9qY3j8HTnNR9M0z/XMZqBb/VJGK+NqNJ+wuhE=; b=ZZuC1EnzUXP4APpy1nWhGnsmVJMnXCx+fbPazKKMeOUF+QYfzOBbwC0zINvdOlq3Dw OfaNhknk+XQqSeArSR7eP35sQ2IC6DiGAxj/m/3Vocqh5cX+mZGjg5dz7JXA3jcQrFPn ZdFCtevALyKgIZyuS/qX2eqCdxd/mVqdyUHSZQCaH5Bx4T8JhsVbCq4xULJAdhGHimE8 I4TeaRWKxdeE85lWt6hDEHfi9MqZCaxEWOOd3gBR/bYx7PeKO/SD2LJmbrSog65Jbjgp jGLrgtJtmLZtKh9fKbdIQCpmSoxXzd6g2WIujvY62gmUcwWCGPAN1F64s34UNFJSnNog C1EQ== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d73-v6si3937161pga.693.2018.09.28.11.20.09; Fri, 28 Sep 2018 11:20:26 -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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727343AbeI2AlU (ORCPT + 99 others); Fri, 28 Sep 2018 20:41:20 -0400 Received: from mga05.intel.com ([192.55.52.43]:26694 "EHLO mga05.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726121AbeI2AlU (ORCPT ); Fri, 28 Sep 2018 20:41:20 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga105.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 28 Sep 2018 11:16:22 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.54,316,1534834800"; d="scan'208";a="94378353" Received: from dwillia2-desk3.jf.intel.com (HELO dwillia2-desk3.amr.corp.intel.com) ([10.54.39.16]) by fmsmga001.fm.intel.com with ESMTP; 28 Sep 2018 11:16:04 -0700 Subject: [PATCH] libnvdimm, region: Fail badblocks listing for inactive regions From: Dan Williams To: linux-nvdimm@lists.01.org Cc: stable@vger.kernel.org, Dave Jiang , Johannes Thumshirn , linux-kernel@vger.kernel.org Date: Fri, 28 Sep 2018 11:04:17 -0700 Message-ID: <153815785702.2023323.12153027860843602654.stgit@dwillia2-desk3.amr.corp.intel.com> User-Agent: StGit/0.18-2-gc94f MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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: Cc: Dave Jiang Cc: Johannes Thumshirn Signed-off-by: Dan Williams --- drivers/nvdimm/region_devs.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/drivers/nvdimm/region_devs.c b/drivers/nvdimm/region_devs.c index fa37afcd43ff..174a418cb171 100644 --- a/drivers/nvdimm/region_devs.c +++ b/drivers/nvdimm/region_devs.c @@ -560,10 +560,17 @@ static ssize_t region_badblocks_show(struct device *dev, 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,