• Ming Lei's avatar
    USB: check sg buffer size in usb_submit_urb · 10e232c5
    Ming Lei authored
    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
    Reported-by: default avatarKonstantin Filatov <kfilatov@parallels.com>
    Reported-by: default avatarDenis V. Lunev <den@openvz.org>
    Cc: Felipe Balbi <balbi@ti.com>
    Acked-by: default avatarAlan Stern <stern@rowland.harvard.edu>
    Signed-off-by: default avatarMing Lei <ming.lei@canonical.com>
    Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
    10e232c5
urb.c 30.2 KB