[PATCH 7/8] staging: unisys: stop device registration before visorbus registration

Sudip Mukherjee sudipm.mukherjee at gmail.com
Mon Aug 24 11:32:35 UTC 2015


On Tue, Aug 18, 2015 at 03:14:02PM -0400, Benjamin Romer wrote:
> In cases where visorbus is compiled directly into the kernel, if
> visorbus registration fails for any reason, it is still possible for
> other drivers to call visorbus_register_visor_driver(), which could
> cause an oops. Prevent this by returning an error code when the bus
> hasn't been registered.
> 
> Signed-off-by: Benjamin Romer <benjamin.romer at unisys.com>
> ---
>  drivers/staging/unisys/visorbus/visorbus_main.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/drivers/staging/unisys/visorbus/visorbus_main.c b/drivers/staging/unisys/visorbus/visorbus_main.c
> index 7905ea9..ad2b1ac 100644
> --- a/drivers/staging/unisys/visorbus/visorbus_main.c
> +++ b/drivers/staging/unisys/visorbus/visorbus_main.c
> @@ -863,6 +863,9 @@ int visorbus_register_visor_driver(struct visor_driver *drv)
>  {
>  	int rc = 0;
>  
> +	if (!visorbus_type.p)
> +		return -ENODEV; /*can't register on a nonexistent bus*/
> +
IIRC, Greg once told that we should not be working with the internal
data structures of struct bus_type.

regards
sudip


More information about the devel mailing list