summaryrefslogtreecommitdiff
path: root/drivers/dax
diff options
context:
space:
mode:
authorUwe Kleine-König <uwe@kleine-koenig.org>2021-02-05 23:28:38 +0100
committerDan Williams <dan.j.williams@intel.com>2021-02-16 19:40:20 -0800
commit5b8e64f1ada37574b9ab124e1414af2adf688a19 (patch)
treebec74af4801780cf4e0f20bba5c855573f5641c0 /drivers/dax
parent7323fb22f05ff1d20498d267828870a5fbbaebd6 (diff)
device-dax: Prevent registering drivers without probe callback
The bus probe function dax_bus_probe() calls the probe callback without checking it to be non-NULL. Prevent a NULL pointer exception if a driver without a probe function is registered by refusing to register this driver. Signed-off-by: Uwe Kleine-König <uwe@kleine-koenig.org> Link: https://lore.kernel.org/r/20210205222842.34896-2-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.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/drivers/dax/bus.c b/drivers/dax/bus.c
index 3003558c1a8b..2b29728ec2fd 100644
--- a/drivers/dax/bus.c
+++ b/drivers/dax/bus.c
@@ -1392,6 +1392,13 @@ int __dax_driver_register(struct dax_device_driver *dax_drv,
struct device_driver *drv = &dax_drv->drv;
int rc = 0;
+ /*
+ * dax_bus_probe() calls dax_drv->probe() unconditionally.
+ * So better be safe than sorry and ensure it is provided.
+ */
+ if (!dax_drv->probe)
+ return -EINVAL;
+
INIT_LIST_HEAD(&dax_drv->ids);
drv->owner = module;
drv->name = mod_name;