Re: [PATCH] usb: ulpi: don't register drivers if bus doesn't exist

From: Sasha Levin
Date: Thu May 28 2015 - 08:37:17 EST


On 05/28/2015 01:39 AM, Sudip Mukherjee wrote:
> diff --git a/drivers/base/driver.c b/drivers/base/driver.c
> index 4eabfe2..1acae5b 100644
> --- a/drivers/base/driver.c
> +++ b/drivers/base/driver.c
> @@ -150,6 +150,11 @@ int driver_register(struct device_driver *drv)
> int ret;
> struct device_driver *other;
>
> + if (!drv->bus->registered) {
> + pr_err("Driver %s registration failed. bus not yet registered\n",
> + drv->name);
> + return -ENODEV;
> + }
> BUG_ON(!drv->bus->p);

This is a design issue with the code in the layer above, there's no reason
driver_register() should be called with a bus that wasn't registered to
begin with.

This is why there's a BUG_ON there to catch these issues - it's a bug, not
a desired behaviour.


Thanks,
Sasha
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/