From patchwork Mon Oct 8 00:42:58 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wei Yongjun X-Patchwork-Id: 1563331 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 C92E0DFF71 for ; Mon, 8 Oct 2012 00:43:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751394Ab2JHAnA (ORCPT ); Sun, 7 Oct 2012 20:43:00 -0400 Received: from mail-qc0-f180.google.com ([209.85.216.180]:65437 "EHLO mail-qc0-f180.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751096Ab2JHAm7 (ORCPT ); Sun, 7 Oct 2012 20:42:59 -0400 Received: by mail-qc0-f180.google.com with SMTP id v28so2495398qcm.11 for ; Sun, 07 Oct 2012 17:42:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:date:message-id:subject:from:to:cc:content-type; bh=OOjxUYbD/3byW6FURzYG8mmcI2NsyZarSVAmlvcmaK4=; b=VAIwFsnshudoGz+INfv/DIOnxc+qvgdt6D+kfELFZTTvYgC60cyPAEZH/5NkkOqGZJ yVyAYQyNDOJds6KgypvWHWg6+khaMIryesvnGH1jIM+G2ixJJytTusVgtLohjWRDHEOl RDnh0iUhPcRYR+ZWJuwuhaXrdWmeKdmIOIcS3cAlIG/Jpn54uIkBZ/O731TSzXJKpeiD wZw+yaUNTXLuhWYsvq3efvQEvTpVUbqmDd0+BgUl9ERU/JmxWyyzBWpcoE+70I52rBZF b20U7YdfBRUu46fy/NaAF5xvA0WhGm2HcgXBySN9Emxm5ZDcMDbmYH0GqGMkYtjQzacx niSA== MIME-Version: 1.0 Received: by 10.229.209.220 with SMTP id gh28mr6448323qcb.19.1349656978838; Sun, 07 Oct 2012 17:42:58 -0700 (PDT) Received: by 10.229.146.194 with HTTP; Sun, 7 Oct 2012 17:42:58 -0700 (PDT) Date: Mon, 8 Oct 2012 08:42:58 +0800 Message-ID: Subject: [PATCH] ath5k: fix potential NULL pointer dereference in ath5k_beacon_update() From: Wei Yongjun To: jirislaby@gmail.com, mickflemm@gmail.com, mcgrof@qca.qualcomm.com, linville@tuxdriver.com Cc: yongjun_wei@trendmicro.com.cn, linux-wireless@vger.kernel.org, ath5k-devel@lists.ath5k.org, netdev@vger.kernel.org Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org From: Wei Yongjun The dereference should be moved below the NULL test. dpatch engine is used to auto generate this patch. (https://github.com/weiyj/dpatch) Signed-off-by: Wei Yongjun --- drivers/net/wireless/ath/ath5k/base.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) -- 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/ath/ath5k/base.c b/drivers/net/wireless/ath/ath5k/base.c index 9fd6d9a..9f31cfa 100644 --- a/drivers/net/wireless/ath/ath5k/base.c +++ b/drivers/net/wireless/ath/ath5k/base.c @@ -1804,7 +1804,7 @@ ath5k_beacon_update(struct ieee80211_hw *hw, struct ieee80211_vif *vif) { int ret; struct ath5k_hw *ah = hw->priv; - struct ath5k_vif *avf = (void *)vif->drv_priv; + struct ath5k_vif *avf; struct sk_buff *skb; if (WARN_ON(!vif)) { @@ -1819,6 +1819,7 @@ ath5k_beacon_update(struct ieee80211_hw *hw, struct ieee80211_vif *vif) goto out; } + avf = (void *)vif->drv_priv; ath5k_txbuf_free_skb(ah, avf->bbuf); avf->bbuf->skb = skb; ret = ath5k_beacon_setup(ah, avf->bbuf);