[PATCH RFC v3 5/9] staging: most: usb: check for NULL device

Greg KH gregkh at linuxfoundation.org
Wed Jan 15 12:18:01 UTC 2020


On Tue, Jan 14, 2020 at 04:57:54PM +0100, Christian Gromm wrote:
> Check if the dci structer has been allocated before trying to release it.
> 
> Signed-off-by: Christian Gromm <christian.gromm at microchip.com>
> ---
> v3:
> 	This patch has been added to the series.
> 
>  drivers/staging/most/usb/usb.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/staging/most/usb/usb.c b/drivers/staging/most/usb/usb.c
> index fe3384a..cae7553 100644
> --- a/drivers/staging/most/usb/usb.c
> +++ b/drivers/staging/most/usb/usb.c
> @@ -1205,8 +1205,10 @@ static void hdm_disconnect(struct usb_interface *interface)
>  	del_timer_sync(&mdev->link_stat_timer);
>  	cancel_work_sync(&mdev->poll_work_obj);
>  
> -	most_put_iface_dev(mdev->dci->dev.parent);
> -	device_unregister(&mdev->dci->dev);
> +	if (mdev->dci) {
> +		most_put_iface_dev(mdev->dci->dev.parent);
> +		device_unregister(&mdev->dci->dev);
> +	}

How can this happen?

And why is it up to the child function here to unregister the device,
that feels wrong, and is further justification to me that your previous
patch is going the wrong way here.

thanks,

greg k-h


More information about the devel mailing list