Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp3281950rwb; Sat, 12 Nov 2022 02:47:50 -0800 (PST) X-Google-Smtp-Source: AA0mqf53l2dC6GaydiZSWLZI8qCz+imSEEYcv17U8yzsfG9miwawEk/gDFP6o912z4Fm8gl3GmVg X-Received: by 2002:a05:6402:5384:b0:458:4868:814 with SMTP id ew4-20020a056402538400b0045848680814mr4919337edb.190.1668250070012; Sat, 12 Nov 2022 02:47:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668250070; cv=none; d=google.com; s=arc-20160816; b=G2SMLw+q/dx4ACveuDQzG89YDtByfakmQ1Xwi7cGdlYxM/DvMk6hLPsFJU7L4fhMTX QieLqwd6tVMB27CAuAZBh4MRwKAFpiYOEKq5QUCHs07YwSa2OYiIWaqxXZMw9u1nBIUX m/2CJGu5hzXu2rowCIUA1P1J3QbC6kClDn3Hf0msppKRRl/EgTGPWhbVy8whHbe3oZjM lTVbVF/SuWs/FPisJoGYJyAfyFn9+c/ctwm/1ttqgxunovUHg3IAGKVnfJgdRsUTNapH f4LQ7YEWrMuuNNOit8IhSvkDtJM6vy13HgdMQSvCX0yXaK2hUSxBbAcbbklvI5e0cyq8 DydQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=XFPATY0qSbr/4BxOYP6cUXPh+6zQbgmtBLgKxuFJzZA=; b=dqfotncWrekfAYBPWBeqQSZPaHa8V2WZL5sQO8xgc50tp4EM/oIzq1JBQv7lKmi+Ql GKfA5M2vc2IycV9OIlQAc5UzGvXXpIUxb/IObDYZExh4qefrI9Ivc01iwfljkbtWeT8V FncERJtoTeZTPgJ/hw2Ila3h7lZ/8peMgCQ4bCfciBydBtZFN3RG2bMEc1YqC/pt8lps 0gXS8QcubQNiqYRZVIKcIzdGQfZRtjDAViVWqgoJMbkzJzQqZ30I5tmbvuZyHOPLvzn8 S8QRMD2qg3aR5QYfICw0Y6CnMUi9O3DOjxv1W379bVAwHhvsYUMBoyAlLaB0mRBL1Jkf nOcg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ne39-20020a1709077ba700b007882926848bsi4887637ejc.818.2022.11.12.02.47.28; Sat, 12 Nov 2022 02:47:50 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232427AbiKLKUS (ORCPT + 90 others); Sat, 12 Nov 2022 05:20:18 -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 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII 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 X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@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); -- 2.25.1