Re: [PATCH v2] USB: check sg buffer size in usb_submit_urb

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

 



On Wed, 26 Jun 2013, Ming Lei wrote:

> USB spec stats that short packet can only appear at the end
> of transfer. Because lost of HC(EHCI/UHCI/OHCI/...) can't
> build a full packet from discontinuous buffers, we introduce
> the limit in usb_submit_urb() to avoid such kind of bad sg buffers
> coming from driver.
> 
> The limit might be a bit strict:
> 	- platform has iommu to do sg list mapping
> 	- some host controllers may support to build full packet from
> 	discontinuous buffers.
> 
> But considered that most of HCs don't support that, and driver
> need work well or keep consistent on different HCs and ARCHs, we
> have to introduce the limit.
> 
> Currently, only usbtest is reported to pass such sg buffers to HC,
> and other users(mass storage, usbfs) don't have the problem.
> 
> We don't check it on USB wireless device, because:
> 	- wireless devices can't be attached to common USB
> 	  bus(EHCI/UHCI/OHCI/...)
> 	- the max packet size of endpoint may be odd, and often can't
> 	devide 4KB which is a typical usage in usb mass storage application

> @@ -413,6 +414,16 @@ int usb_submit_urb(struct urb *urb, gfp_t mem_flags)
>  			urb->iso_frame_desc[n].status = -EXDEV;
>  			urb->iso_frame_desc[n].actual_length = 0;
>  		}
> +	} else {
> +		/* check sg buffer size */
> +		if (dev->speed != USB_SPEED_WIRELESS && urb->num_sgs) {
> +			struct scatterlist *sg;
> +			int i;

Like Sergei said, you can save one level of indentation by converting 
this to

	}

	/* check SG buffer sizes */
	else if (dev->speed ...

Aside from that,

Acked-by: Alan Stern <stern@xxxxxxxxxxxxxxxxxxx>

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