From patchwork Thu Mar 12 11:33:56 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yang Bai X-Patchwork-Id: 5992821 X-Patchwork-Delegate: kvalo@adurom.com 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.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 2EB98BF90F for ; Thu, 12 Mar 2015 11:32:00 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 5C8B12041F for ; Thu, 12 Mar 2015 11:31:59 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id D663820397 for ; Thu, 12 Mar 2015 11:31:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753787AbbCLLbf (ORCPT ); Thu, 12 Mar 2015 07:31:35 -0400 Received: from mail-pa0-f47.google.com ([209.85.220.47]:39954 "EHLO mail-pa0-f47.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753693AbbCLLbd (ORCPT ); Thu, 12 Mar 2015 07:31:33 -0400 Received: by padfb1 with SMTP id fb1so19853690pad.7; Thu, 12 Mar 2015 04:31:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=AsFoA1Qq09g/WIHKhwQLHYzqdlPzKU2Hbc/4KLpY6a8=; b=DHcqtTaLIGSVbQlk9xrn5a2EVi/5b0NmB3VNpPGzrB9ePL0VVQc7myRM16To52u7BL jTedVeMmfiYpO80kR+Ii5bfH8lBZLeHz54Cpz/yg8h7feqDkf0f4GapMZzBhaytUeUb6 WzymgUeKMQbmUjHqLLzrbEW4brVJq5dxRDxe8PKHnGUGgA1IUfuGt2lOT36+UpVfdbd/ G/cG5ql4ZPoBmZA08F8fhvSrIFaHTXDo+l2ju8pwrhLEGcd10nJEXoBeL/3MzCvNRuzw 1GxZEwNrBOsSKJc1zPs7uAj8kdvTzE81oLLrZL19sqz3WijCaU7QExk5r/6QJzbrNmYO o01g== X-Received: by 10.70.1.103 with SMTP id 7mr4646015pdl.4.1426159893134; Thu, 12 Mar 2015 04:31:33 -0700 (PDT) Received: from TRINITY.localdomain ([198.199.110.226]) by mx.google.com with ESMTPSA id os6sm10617609pac.28.2015.03.12.04.31.28 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 12 Mar 2015 04:31:32 -0700 (PDT) From: Yang Bai To: Larry.Finger@lwfinger.net, chaoming_li@realsil.com.cn, kvalo@codeaurora.org Cc: linux-wireless@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, hamo.by@gmail.com Subject: [PATCH] rtlwifi: get buffer_desc before trying to alloc new skb Date: Thu, 12 Mar 2015 19:33:56 +0800 Message-Id: <1426160036-1542-1-git-send-email-hamo.by@gmail.com> X-Mailer: git-send-email 2.3.1 Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, T_DKIM_INVALID, T_RP_MATCHES_RCVD, 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 if rtlpriv->use_new_trx_flow == true and we run out of memory to alloc a new skb, we will directly jump to no_new tag with buffer_desc == NULL. Then we will dereference this NULL pointer in function _rtl_pci_init_one_rxdesc. Signed-off-by: Yang Bai --- drivers/net/wireless/rtlwifi/pci.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/drivers/net/wireless/rtlwifi/pci.c b/drivers/net/wireless/rtlwifi/pci.c index a62170e..7fe04d1 100644 --- a/drivers/net/wireless/rtlwifi/pci.c +++ b/drivers/net/wireless/rtlwifi/pci.c @@ -820,17 +820,19 @@ static void _rtl_pci_rx_interrupt(struct ieee80211_hw *hw) pci_unmap_single(rtlpci->pdev, *((dma_addr_t *)skb->cb), rtlpci->rxbuffersize, PCI_DMA_FROMDEVICE); + if (rtlpriv->use_new_trx_flow) + buffer_desc = + &rtlpci->rx_ring[rxring_idx].buffer_desc + [rtlpci->rx_ring[rxring_idx].idx]; + /* get a new skb - if fail, old one will be reused */ new_skb = dev_alloc_skb(rtlpci->rxbuffersize); if (unlikely(!new_skb)) goto no_new; - if (rtlpriv->use_new_trx_flow) { - buffer_desc = - &rtlpci->rx_ring[rxring_idx].buffer_desc - [rtlpci->rx_ring[rxring_idx].idx]; + if (rtlpriv->use_new_trx_flow) /*means rx wifi info*/ pdesc = (struct rtl_rx_desc *)skb->data; - } + memset(&rx_status , 0 , sizeof(rx_status)); rtlpriv->cfg->ops->query_rx_desc(hw, &stats, &rx_status, (u8 *)pdesc, skb);