From patchwork Sat Nov 12 11:07:54 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Liu Shixin X-Patchwork-Id: 13041138 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 89132C4332F for ; Sat, 12 Nov 2022 10:20:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230327AbiKLKUR (ORCPT ); Sat, 12 Nov 2022 05:20:17 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45356 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230170AbiKLKUQ (ORCPT ); Sat, 12 Nov 2022 05:20:16 -0500 Received: from szxga03-in.huawei.com (szxga03-in.huawei.com [45.249.212.189]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1C219BC14; Sat, 12 Nov 2022 02:20:15 -0800 (PST) Received: from dggpemm500022.china.huawei.com (unknown [172.30.72.57]) by szxga03-in.huawei.com (SkyGuard) with ESMTP id 4N8Whg27ryzJnWV; Sat, 12 Nov 2022 18:17:07 +0800 (CST) Received: from dggpemm100009.china.huawei.com (7.185.36.113) by dggpemm500022.china.huawei.com (7.185.36.162) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Sat, 12 Nov 2022 18:20:11 +0800 Received: from huawei.com (10.175.113.32) by dggpemm100009.china.huawei.com (7.185.36.113) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Sat, 12 Nov 2022 18:20:11 +0800 From: Liu Shixin To: Jens Axboe CC: , , Liu Shixin Subject: [PATCH] blk-mq: only unregister sysfs when registration succeeded Date: Sat, 12 Nov 2022 19:07:54 +0800 Message-ID: <20221112110754.1109979-1-liushixin2@huawei.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 X-Originating-IP: [10.175.113.32] X-ClientProxiedBy: dggems703-chm.china.huawei.com (10.3.19.180) To dggpemm100009.china.huawei.com (7.185.36.113) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org kobject_del() must not be called if kobject_add() has not been called. Hence only unregister sysfs when registration succeeded. Signed-off-by: Liu Shixin --- block/blk-mq-sysfs.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/block/blk-mq-sysfs.c b/block/blk-mq-sysfs.c index 93997d297d42..63f2df2500d9 100644 --- a/block/blk-mq-sysfs.c +++ b/block/blk-mq-sysfs.c @@ -279,6 +279,8 @@ void blk_mq_sysfs_unregister(struct gendisk *disk) unsigned long i; lockdep_assert_held(&q->sysfs_dir_lock); + if (!q->mq_sysfs_init_done) + return; queue_for_each_hw_ctx(q, hctx, i) blk_mq_unregister_hctx(hctx);