Re: [PATCH] usb: storage: fix lockdep warning inside usb_stor_pre_reset

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

 



On Thu, 15 Mar 2012, Ming Lei wrote:

> --- a/drivers/usb/storage/usb.c
> +++ b/drivers/usb/storage/usb.c
> @@ -197,8 +197,13 @@ int usb_stor_pre_reset(struct usb_interface *iface)
>  
>  	US_DEBUGP("%s\n", __func__);
>  
> -	/* Make sure no command runs during the reset */
> -	mutex_lock(&us->dev_mutex);
> +	/*
> +	 * Make sure no command runs during the reset. And take
> +	 * the nested annotation to avoid 'AA' lockdep warning
> +	 * for multiple mass storage interfaces' case.
> +	 */
> +	mutex_lock_nested(&us->dev_mutex,
> +		(int)(iface - us->pusb_dev->actconfig->interface[0]));

I realize this is going to be changed... but it's worth pointing out
that this expression is wrong.  It will remain wrong if it is copied in
the new patch.

iface does not point to a member of an array, so taking the difference
of the two pointers gives a meaningless result.  To do this correctly 
requires searching for the interface pointer:

	struct usb_host_config *config = us->pusb_dev->actconfig;
	int i;

	for (i = 0; i < config->desc.bNumInterfaces; ++i) {
		if (config->interface[i] == intf)
			break;
	}
	lockdep_set_class(&us->dev_mutex, &usb_interface_key[i]);

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