From patchwork Wed Jan 27 23:01:23 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= X-Patchwork-Id: 12051157 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.9 required=3.0 tests=BAYES_50, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6585FC433E0 for ; Wed, 27 Jan 2021 23:01:34 +0000 (UTC) Received: from ml01.01.org (ml01.01.org [198.145.21.10]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 9A5A360C3D for ; Wed, 27 Jan 2021 23:01:33 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 9A5A360C3D Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=kleine-koenig.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-nvdimm-bounces@lists.01.org Received: from ml01.vlan13.01.org (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 3BEFF100EB343; Wed, 27 Jan 2021 15:01:33 -0800 (PST) Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=94.130.110.236; helo=antares.kleine-koenig.org; envelope-from=uwe@kleine-koenig.org; receiver= Received: from antares.kleine-koenig.org (antares.kleine-koenig.org [94.130.110.236]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id C1EFD100EB33F for ; Wed, 27 Jan 2021 15:01:29 -0800 (PST) Received: by antares.kleine-koenig.org (Postfix, from userid 1000) id 21E01AE0D2C; Thu, 28 Jan 2021 00:01:27 +0100 (CET) From: =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= To: Dan Williams , Vishal Verma , Dave Jiang Subject: [PATCH 2/3] dax-device: Fix error path in dax_driver_register Date: Thu, 28 Jan 2021 00:01:23 +0100 Message-Id: <20210127230124.109522-2-uwe@kleine-koenig.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210127230124.109522-1-uwe@kleine-koenig.org> References: <20210127230124.109522-1-uwe@kleine-koenig.org> MIME-Version: 1.0 Message-ID-Hash: WMEDCSPGTV5FL6FT6WAJ2OIADNK3BJRW X-Message-ID-Hash: WMEDCSPGTV5FL6FT6WAJ2OIADNK3BJRW X-MailFrom: uwe@kleine-koenig.org X-Mailman-Rule-Hits: nonmember-moderation X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation CC: linux-nvdimm@lists.01.org, linux-kernel@vger.kernel.org, Greg Kroah-Hartman X-Mailman-Version: 3.1.1 Precedence: list List-Id: "Linux-nvdimm developer list." Archived-At: List-Archive: List-Help: List-Post: List-Subscribe: List-Unsubscribe: The static variable match_always_count is supposed to track if there is a driver registered that has .match_always set. If driver_register() fails, the previous increment must be undone. Signed-off-by: Uwe Kleine-König --- drivers/dax/bus.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/drivers/dax/bus.c b/drivers/dax/bus.c index 618d462975ba..498c60333d60 100644 --- a/drivers/dax/bus.c +++ b/drivers/dax/bus.c @@ -1417,7 +1417,15 @@ int __dax_driver_register(struct dax_device_driver *dax_drv, mutex_unlock(&dax_bus_lock); if (rc) return rc; - return driver_register(drv); + + rc = driver_register(drv); + if (rc && dax_drv->match_always) { + mutex_lock(&dax_bus_lock); + match_always_count -= dax_drv->match_always; + mutex_unlock(&dax_bus_lock); + } + + return rc; } EXPORT_SYMBOL_GPL(__dax_driver_register);