rtlwifi: usb: allocate URB control message setup_packet and data buffer separately
authorJussi Kivilinna <jussi.kivilinna@mbnet.fi>
Mon, 18 Feb 2013 08:29:30 +0000 (10:29 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 27 Feb 2013 17:21:07 +0000 (09:21 -0800)
commitd3b1b29819924e0224648d9c33bb15ec768cfe33
tree4b92c203ef7ad5f6894b4db1a645eea0851db438
parent25813769478011277a394700e001b91892d393a5
rtlwifi: usb: allocate URB control message setup_packet and data buffer separately

commit bc6b89237acb3dee6af6e64e51a18255fef89cc2 upstream.

rtlwifi allocates both setup_packet and data buffer of control message urb,
using shared kmalloc in _usbctrl_vendorreq_async_write. Structure used for
allocating is:
struct {
u8 data[254];
struct usb_ctrlrequest dr;
};

Because 'struct usb_ctrlrequest' is __packed, setup packet is unaligned and
DMA mapping of both 'data' and 'dr' confuses ARM/sunxi, leading to memory
corruptions and freezes.

Patch changes setup packet to be allocated separately.

[v2]:
 - Use WARN_ON_ONCE instead of WARN_ON

Signed-off-by: Jussi Kivilinna <jussi.kivilinna@mbnet.fi>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/net/wireless/rtlwifi/usb.c