Re: [PATCH v2] usb: core: Warn if an URB's transfer_buffer is on stack
From: Clemens Ladisch
Date: Mon Apr 24 2017 - 03:22:54 EST
Florian Fainelli wrote:
> We see a large number of fixes to several drivers to remove the usage of
> on-stack buffers feeding into USB transfer functions. Make it easier to spot
> the offenders by adding a warning in usb_hcd_map_urb_for_dma() checking that
> urb->transfer_buffer is not a stack object.
This description is incomplete.
> + } else if (object_is_on_stack(urb->transfer_buffer)) {
> + WARN_ONCE(1, "transfer buffer is on stack\n");
> + ret = -EAGAIN;
> } else {
> urb->transfer_dma = dma_map_single(
Not only is there a warning, but the check also forces all those URBs
to abort with an error.
Well, that makes it even easier to spot the offenders ...
Regards,
Clemens