rtlwifi: fix incorrect use of usb_alloc_coherent with usb_control_msg
authorJussi Kivilinna <jussi.kivilinna@mbnet.fi>
Thu, 20 Dec 2012 14:24:43 +0000 (16:24 +0200)
committerJohn W. Linville <linville@tuxdriver.com>
Wed, 2 Jan 2013 19:38:24 +0000 (14:38 -0500)
Incorrect use of usb_alloc_coherent memory as input buffer to usb_control_msg
can cause problems in arch DMA code, for example kernel BUG at
'arch/arm/include/asm/dma-mapping.h:321' on ARM (linux-3.4).

Change _usb_writeN_sync use kmalloc'd buffer instead.

Cc: stable@vger.kernel.org
Signed-off-by: Jussi Kivilinna <jussi.kivilinna@mbnet.fi>
Acked-by: Larry Finger <Larry.Finger@lwfinger.net>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
drivers/net/wireless/rtlwifi/usb.c

index 29f0969e4ba00cd3dd299c209ac09f594346b168..a3312b7c49073ddf6ddf42bc6e2d3f3753b36f6d 100644 (file)
@@ -210,17 +210,16 @@ static void _usb_writeN_sync(struct rtl_priv *rtlpriv, u32 addr, void *data,
        u16 index = REALTEK_USB_VENQT_CMD_IDX;
        int pipe = usb_sndctrlpipe(udev, 0); /* write_out */
        u8 *buffer;
-       dma_addr_t dma_addr;
 
-       wvalue = (u16)(addr&0x0000ffff);
-       buffer = usb_alloc_coherent(udev, (size_t)len, GFP_ATOMIC, &dma_addr);
+       wvalue = (u16)(addr & 0x0000ffff);
+       buffer = kmalloc(len, GFP_ATOMIC);
        if (!buffer)
                return;
        memcpy(buffer, data, len);
        usb_control_msg(udev, pipe, request, reqtype, wvalue,
                        index, buffer, len, 50);
 
-       usb_free_coherent(udev, (size_t)len, buffer, dma_addr);
+       kfree(buffer);
 }
 
 static void _rtl_usb_io_handler_init(struct device *dev,