summaryrefslogtreecommitdiff
path: root/drivers/dax
diff options
context:
space:
mode:
authorUwe Kleine-König <uwe@kleine-koenig.org>2021-02-06 01:28:40 +0300
committerDan Williams <dan.j.williams@intel.com>2021-02-17 06:42:03 +0300
commite307bf11c5198dbc0c9de0694c3e85c681648df6 (patch)
treec57c89a6e402e3360c11e8f29208c78315983ec4 /drivers/dax
parent8029968e2ae02361f376751459dc644b45970b40 (diff)
downloadlinux-e307bf11c5198dbc0c9de0694c3e85c681648df6.tar.xz
device-dax: Fix error path in dax_driver_register
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 <uwe@kleine-koenig.org> Link: https://lore.kernel.org/r/20210205222842.34896-4-uwe@kleine-koenig.org Signed-off-by: Dan Williams <dan.j.williams@intel.com>
Diffstat (limited to 'drivers/dax')
-rw-r--r--drivers/dax/bus.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/drivers/dax/bus.c b/drivers/dax/bus.c
index ef53da441c5d..d2419e88073a 100644
--- a/drivers/dax/bus.c
+++ b/drivers/dax/bus.c
@@ -1420,7 +1420,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);