From patchwork Sat Feb 22 16:57:23 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrea Merello X-Patchwork-Id: 3701491 Return-Path: X-Original-To: patchwork-linux-wireless@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 2F0F2BF40C for ; Sat, 22 Feb 2014 16:57:01 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 59B7A201BF for ; Sat, 22 Feb 2014 16:57:00 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 39A07201DD for ; Sat, 22 Feb 2014 16:56:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751914AbaBVQ44 (ORCPT ); Sat, 22 Feb 2014 11:56:56 -0500 Received: from mail-ea0-f180.google.com ([209.85.215.180]:35731 "EHLO mail-ea0-f180.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751885AbaBVQ4w (ORCPT ); Sat, 22 Feb 2014 11:56:52 -0500 Received: by mail-ea0-f180.google.com with SMTP id o10so2212615eaj.39 for ; Sat, 22 Feb 2014 08:56:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=Q1YYY9LZsCTD1ClpjyV27j2Qon8LFbANNptlfT5MN3k=; b=onPb5GKu/Ko5nVdzON8lHc+vB7m3hRbHbI7Q9JKCux0DdFDXVFooRXNkOk4qyRMr+T hPhzu3CRCrmAuL9ABtwiTziKW3ug7JMRv9D7TUp35SvAdyiajwqR26861yfVe9AZN2MK PlS4UUIzecU9X4CIxlqp2LFGcfm1eLGuU7HcenK5a60r7PE+2Tf+aUbLRgIcxgLpc2V0 +m/DuiJ/+q5+zVnG95BRwV2e40aNC2L4cW7Fu7op+ZC7x8VdRcRHC9labzo+dUXDQjaW WRA5/PKGrDOWZ6GyD9CRi7sPF6LSVorLI01IQZfIJgk1zsl2+QRncglooK2L/wzDJRUI Abew== X-Received: by 10.15.56.130 with SMTP id y2mr15242293eew.17.1393088211730; Sat, 22 Feb 2014 08:56:51 -0800 (PST) Received: from localhost.localdomain ([95.237.125.26]) by mx.google.com with ESMTPSA id n41sm40809619eeg.16.2014.02.22.08.56.50 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sat, 22 Feb 2014 08:56:51 -0800 (PST) From: Andrea Merello To: dan.carpenter@oracle.com, linville@tuxdriver.com Cc: linux-wireless@vger.kernel.org, Larry.Finger@lwfinger.net, bernhard@schiffner-limbach.de, andrea merello Subject: [PATCH 3/7 V2] rtl818x: check for pci_map_single() success when initializing RX ring Date: Sat, 22 Feb 2014 17:57:23 +0100 Message-Id: <1393088243-22740-1-git-send-email-andrea.merello@gmail.com> X-Mailer: git-send-email 1.8.3.2 In-Reply-To: References: Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org X-Spam-Status: No, score=-7.3 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: andrea merello During initialization a number of RX skbs are allocated and mapped for DMA. Currently if pci_map_single() fails, it will result in passing to the HW a wrong DMA address (to write to!). This patch adds check for this condition and eventually causes the driver not to initialize, avoiding at least dangerous DMAs. Signed-off-by: Andrea Merello --- drivers/net/wireless/rtl818x/rtl8180/dev.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/drivers/net/wireless/rtl818x/rtl8180/dev.c b/drivers/net/wireless/rtl818x/rtl8180/dev.c index bf59ff9..0102da2 100644 --- a/drivers/net/wireless/rtl818x/rtl8180/dev.c +++ b/drivers/net/wireless/rtl818x/rtl8180/dev.c @@ -483,6 +483,13 @@ static int rtl8180_init_rx_ring(struct ieee80211_hw *dev) mapping = (dma_addr_t *)skb->cb; *mapping = pci_map_single(priv->pdev, skb_tail_pointer(skb), MAX_RX_SIZE, PCI_DMA_FROMDEVICE); + + if (pci_dma_mapping_error(priv->pdev, *mapping)) { + kfree_skb(skb); + wiphy_err(dev->wiphy, "Cannot map DMA for RX skb\n"); + return -ENOMEM; + } + entry->rx_buf = cpu_to_le32(*mapping); entry->flags = cpu_to_le32(RTL818X_RX_DESC_FLAG_OWN | MAX_RX_SIZE);