From patchwork Thu Dec 20 14:24:43 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jussi Kivilinna X-Patchwork-Id: 1899871 Return-Path: X-Original-To: patchwork-linux-wireless@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork2.kernel.org (Postfix) with ESMTP id 35411DF23A for ; Thu, 20 Dec 2012 14:24:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750984Ab2LTOYq (ORCPT ); Thu, 20 Dec 2012 09:24:46 -0500 Received: from sd-mail-sa-01.sanoma.fi ([158.127.18.161]:59894 "EHLO sd-mail-sa-01.sanoma.fi" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750838Ab2LTOYp (ORCPT ); Thu, 20 Dec 2012 09:24:45 -0500 Received: from localhost (localhost [127.0.0.1]) by sd-mail-sa-01.sanoma.fi (Postfix) with ESMTP id 5827DF2D9E; Thu, 20 Dec 2012 16:24:44 +0200 (EET) Received: from sd-mail-sa-01.sanoma.fi ([127.0.0.1]) by localhost (sd-mail-sa-01.sanoma.fi [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id uFUgRWO7Hrum; Thu, 20 Dec 2012 16:24:44 +0200 (EET) Received: from hayate.dalek.fi (dyn2-212-50-133-218.psoas.suomi.net [212.50.133.218]) (Authenticated sender: axh) by sd-mail-sa-01.sanoma.fi (Postfix) with ESMTPSA id 04880F2D05; Thu, 20 Dec 2012 16:24:44 +0200 (EET) Received: from fate.lan ([10.0.0.10] helo=fate) by hayate.dalek.fi with esmtp (Exim 4.72) (envelope-from ) id 1Tlh3D-0001xg-Hr; Thu, 20 Dec 2012 16:24:43 +0200 Received: from localhost6.localdomain6 (unknown [127.0.0.1]) by fate (Postfix) with ESMTP id 8094E20093D; Thu, 20 Dec 2012 16:24:43 +0200 (EET) Subject: [PATCH] rtlwifi: fix incorrect use of usb_alloc_coherent with usb_control_msg To: linux-wireless@vger.kernel.org From: Jussi Kivilinna Cc: Chaoming Li , "John W. Linville" , stable@vger.kernel.org, Larry Finger Date: Thu, 20 Dec 2012 16:24:43 +0200 Message-ID: <20121220142443.16895.45834.stgit@localhost6.localdomain6> User-Agent: StGit/0.15 MIME-Version: 1.0 Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org 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 Acked-by: Larry Finger --- drivers/net/wireless/rtlwifi/usb.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) -- To unsubscribe from this list: send the line "unsubscribe linux-wireless" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/net/wireless/rtlwifi/usb.c b/drivers/net/wireless/rtlwifi/usb.c index 29f0969..a3312b7 100644 --- a/drivers/net/wireless/rtlwifi/usb.c +++ b/drivers/net/wireless/rtlwifi/usb.c @@ -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,