driver: bail out, don't crash, if drv->name is not set
Currently, we expect each driver to have a name. If a driver doesn't, we run into a NULL pointer dereference. Make this error scenario more pleasant by checking if a name is set and failing otherwise. The only in-tree driver affected by this is drivers/watchdog/dw_wdt.c, which will be fixed in the follow-up commit. Affected drivers can be determined with following pipeline, which should return all driver_d structure instantiations that don't contain a name: ack --A 4 'struct driver_d.*' | perl -pe 's/^--$/\n/' | \ perl -000 -ne 'print if /=.*\{.*\}/s && !/name/s' With this change, these drivers should now give a more pleasant message: ERROR: initcall dw_wdt_driver_register+0x1/0xc failed: Invalid argument Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de> |
---|
|
drivers/base/driver.c |
---|