Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3477819imu; Sun, 11 Nov 2018 16:01:34 -0800 (PST) X-Google-Smtp-Source: AJdET5cNTlqrXqWK9lX8NvGNt/rXIiPAcFNQ3RhJ9baDhfSE9Zu2nod7Cr6QwWaWkJnEd8DfhJdq X-Received: by 2002:a63:1b48:: with SMTP id b8mr15635172pgm.187.1541980894868; Sun, 11 Nov 2018 16:01:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541980894; cv=none; d=google.com; s=arc-20160816; b=DaM2CezF6MbD9lyqwiBaV7OCgmSgGX0QOfk6DpCRZO1T+A3+BOt26g5wvK1andvpyZ xZ1aTr+D9iC7mLDH8xXtzccS2eUQ8Sb8X/DfHzhNL2lpONMFFFjKrqTK5ulPzw1VqMZQ idBBfuKItgst9vblCjPTDFH0oaHNJ58whMmK/STLpGkXWDjBR+ZojYu55kEYLN5cs2BJ tOzJ80sMzwTvzFiRTOspM+2IG7lAYuzpLqjOtL3ArwYHj0E35bQmqewQPGSlEiH71NS4 kY7UZTiPjXvQiUXVmDZu3cFqeOsEtOhQ5wjBF5ySqL+FYx+xY/yJly4J6gOqxjG58iHg dpHg== 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=nbX7d00ANyHB6TEG9DRZ3E8k7mH6M9c6BH2lAjh+Tsc=; b=TdqFY1vHXqt63AMa1Ljs55iyyH8EqDC67n7sLZjhoIW9x3gRaD/cgc2wWwFgOe8b3l 8wUS2473M2YCXHUwD5g1QnXu1Epj4SyVuqwzRkJzxM4zQBlT50nTylMFmfoXeOKGyuF9 xCHKEPq0xj7zf5y/QGTAAbcD5Vh5abBlE4aeyvFmynpdMCgWrFQl8WyXdb4IOP1pn3/c f8RtViMaR/1IETrWZeiUMkwDlgQtLTE33b3lqoNxm8r0uydjpB9JaHJWovIisQprFWcB SjdVBGy6Icuf6PuJ9Jt1Fd125ydd5XVfUQPl+ivos90gZxj0p8qse9bq6S4XefqVy+bg Ctlg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=ycWvke5R; 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 h13-v6si13535062pgq.285.2018.11.11.16.01.19; Sun, 11 Nov 2018 16:01:34 -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=ycWvke5R; 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 S1732354AbeKLISC (ORCPT + 99 others); Mon, 12 Nov 2018 03:18:02 -0500 Received: from mail.kernel.org ([198.145.29.99]:34210 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732334AbeKLISC (ORCPT ); Mon, 12 Nov 2018 03:18:02 -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 3F1F7223D0; Sun, 11 Nov 2018 22:28:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1541975286; bh=mfhoa4b5MPctdjhirw58OiOvdVTQ6sx43aKsk1fgrBg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ycWvke5Rrm/d0MCIBrcVYEMfWw+MPEwDzotJB04nK2uS/sdLeiIODTOYJ/P5LX/cK PltJJG9nla51+yziDvlgCz0fib1hQum5sc8PK2fTlLRHBU9xnUJVVMLjgHMDoJfobV UHSwhOIoWFXD3UopFFnkxC6lmd62YVzfHXwNkMAg= 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.19 218/361] libnvdimm, region: Fail badblocks listing for inactive regions Date: Sun, 11 Nov 2018 14:19:25 -0800 Message-Id: <20181111221650.401857603@linuxfoundation.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181111221619.915519183@linuxfoundation.org> References: <20181111221619.915519183@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.19-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 @@ -560,10 +560,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,