Re: [PATCH] usb: ulpi: call put_device if device_register fails
From: Heikki Krogerus
Date: Tue Jun 23 2015 - 06:57:55 EST
On Fri, Jun 19, 2015 at 01:12:36AM +0800, ChengYi He wrote:
> put_device is required to release the last reference to the device.
>
> Signed-off-by: ChengYi He <chengyihetaipei@xxxxxxxxx>
> ---
> drivers/usb/common/ulpi.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/usb/common/ulpi.c b/drivers/usb/common/ulpi.c
> index 0e6f968..bd25bdb 100644
> --- a/drivers/usb/common/ulpi.c
> +++ b/drivers/usb/common/ulpi.c
> @@ -184,8 +184,10 @@ static int ulpi_register(struct device *dev, struct ulpi *ulpi)
> request_module("ulpi:v%04xp%04x", ulpi->id.vendor, ulpi->id.product);
>
> ret = device_register(&ulpi->dev);
> - if (ret)
> + if (ret) {
> + put_device(&ulpi->dev);
If device_register returns failure, put_device has already been
called. Check device_add in drivers/base/core.c.
Thanks,
--
heikki
--
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/