Messages in this thread Patch in this message | | | From | Uwe Kleine-König <> | Subject | [PATCH v2 1/5] dax-device: Prevent registering drivers without probe callback | Date | Fri, 5 Feb 2021 23:28:38 +0100 |
| |
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> --- drivers/dax/bus.c | 7 +++++++ 1 file changed, 7 insertions(+)
diff --git a/drivers/dax/bus.c b/drivers/dax/bus.c index 737b207c9e30..72fc4b9b9ae6 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; -- 2.29.2
| |