Re: [PATCH] USB:serial: fix deadlock caused by reseting device in .close

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, 7 Apr 2009 tom.leiming@xxxxxxxxx wrote:

> From: Ming Lei <tom.leiming@xxxxxxxxx>
> 
> The deadlock is caused by mutex_lock(&port->serial->disc_mutex)
> (called in garmin_close() and usb_serial_disconnect() ). The garmin
> usb_driver doesn't define .pre_reset and .post_reset, so
> usb_reset_devie() will unbound garmin usb_driver before doing bus
> reset, which makes .disconnect() called, then deadlock happens.
> 
> This patch defines .pre_reset and .post_reset in garmin usb_driver
> to prevent the usb driver from being unbound in usb_reset_device()
> called by garmin_close.
> 
> This patch fixes the bug reported in the link:
> 	http://bugs.archlinux.org/task/12079
> 
> Signed-off-by: Ming Lei <tom.leiming@xxxxxxxxx>
> Reported-by:Hal Murray <hmurray@xxxxxxxxxxxxxxx>
> Tested-by:Hal Murray <hmurray@xxxxxxxxxxxxxxx>
> ---
>  drivers/usb/serial/garmin_gps.c |   12 ++++++++++++
>  1 files changed, 12 insertions(+), 0 deletions(-)
> 
> diff --git a/drivers/usb/serial/garmin_gps.c b/drivers/usb/serial/garmin_gps.c
> index a26a0e2..8c8b716 100644
> --- a/drivers/usb/serial/garmin_gps.c
> +++ b/drivers/usb/serial/garmin_gps.c
> @@ -224,10 +224,22 @@ static struct usb_device_id id_table [] = {
>  
>  MODULE_DEVICE_TABLE(usb, id_table);
>  
> +static int  garmin_pre_reset(struct usb_interface *intf)
> +{
> +	return 0;
> +}
> +
> +static int  garmin_post_reset(struct usb_interface *intf)
> +{
> +	return 0;
> +}
> +
>  static struct usb_driver garmin_driver = {
>  	.name =		"garmin_gps",
>  	.probe =	usb_serial_probe,
>  	.disconnect =	usb_serial_disconnect,
> +	.pre_reset   =   garmin_pre_reset,
> +	.post_reset  =   garmin_post_reset,
>  	.id_table =	id_table,
>  	.no_dynamic_id = 1,
>  };

This patch fixes the immediate symptom but not the underlying problem,
which is that garmin_gps does several things wrong in its close method.

Alan Stern

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux