Message ID | 20210624095059.4010157-2-sudeep.holla@arm.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | [1/2] firmware: arm_scmi: Simplify device probe function on the bus | expand |
Hi, On Thu, Jun 24, 2021 at 10:50:59AM +0100, Sudeep Holla wrote: > The bus probe callback calls the driver callback without further > checking. Better be safe than sorry and refuse registration of a driver > without a probe function to prevent a NULL pointer exception. > > Fixes: 933c504424a2 ("firmware: arm_scmi: add scmi protocol bus to enumerate protocol devices") > Reported-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> > Signed-off-by: Sudeep Holla <sudeep.holla@arm.com> > --- > drivers/firmware/arm_scmi/bus.c | 3 +++ > 1 file changed, 3 insertions(+) > > diff --git a/drivers/firmware/arm_scmi/bus.c b/drivers/firmware/arm_scmi/bus.c > index dc113ad37ad9..6c7e24935eca 100644 > --- a/drivers/firmware/arm_scmi/bus.c > +++ b/drivers/firmware/arm_scmi/bus.c > @@ -134,6 +134,9 @@ int scmi_driver_register(struct scmi_driver *driver, struct module *owner, > { > int retval; > > + if (!driver->probe) > + return -EINVAL; > + > retval = scmi_protocol_device_request(driver->id_table); > if (retval) > return retval; Reviewed-by: Cristian Marussi <cristian.marussi@arm.com> Tested-by: Cristian Marussi <cristian.marussi@arm.com> Thanks, Cristian > -- > 2.25.1 >
On Thu, Jun 24, 2021 at 10:50:59AM +0100, Sudeep Holla wrote: > The bus probe callback calls the driver callback without further > checking. Better be safe than sorry and refuse registration of a driver > without a probe function to prevent a NULL pointer exception. > > Fixes: 933c504424a2 ("firmware: arm_scmi: add scmi protocol bus to enumerate protocol devices") > Reported-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> > Signed-off-by: Sudeep Holla <sudeep.holla@arm.com> Acked-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Thanks to pick my "suggestion" up also for scmi. Best regards Uwe
diff --git a/drivers/firmware/arm_scmi/bus.c b/drivers/firmware/arm_scmi/bus.c index dc113ad37ad9..6c7e24935eca 100644 --- a/drivers/firmware/arm_scmi/bus.c +++ b/drivers/firmware/arm_scmi/bus.c @@ -134,6 +134,9 @@ int scmi_driver_register(struct scmi_driver *driver, struct module *owner, { int retval; + if (!driver->probe) + return -EINVAL; + retval = scmi_protocol_device_request(driver->id_table); if (retval) return retval;
The bus probe callback calls the driver callback without further checking. Better be safe than sorry and refuse registration of a driver without a probe function to prevent a NULL pointer exception. Fixes: 933c504424a2 ("firmware: arm_scmi: add scmi protocol bus to enumerate protocol devices") Reported-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Signed-off-by: Sudeep Holla <sudeep.holla@arm.com> --- drivers/firmware/arm_scmi/bus.c | 3 +++ 1 file changed, 3 insertions(+)