Re: [PATCH] usb: core: Warn if an URB's transfer_buffer is on stack
From: Alan Stern
Date: Sun Apr 23 2017 - 20:03:39 EST
On Sun, 23 Apr 2017, Florian Fainelli wrote:
> > In that case, it would be better to move the warning to a central place
> > where it will always get triggered, such as map_urb_for_dma(). As it
> > is, the patch will only issue a warning for callers of usb_bulk_msg(),
> > usb_interrupt_msg(), or usb_control_msg().
>
> map_urb_for_dma() seems like a better location indeed, let me submit a
> v2 with that then.
>
> Most HCDs implementation that define a map_urb_for_dma function pointer
> also call usb_hcd_map_urb_for_dma() (except for max3421-hcd.c) so would
> it be better to move the is_object_on_stack() check in
> usb_hcd_map_urb_for_dma() for consistency with the existing
> is_vmalloc_addr() check?
Or maybe move the is_vmalloc_addr() check to map_urb_for_dma().
The only issue is that some weird HCD might sometimes not need to do
the DMA mapping (it might use PIO for some types of transfer). In
those cases we don't want to issue the warning. So perhaps
usb_hcd_map_urb_for_dma() would be better for both checks.
Alan Stern