From patchwork Wed May 7 07:22:58 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Herrmann X-Patchwork-Id: 4125891 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 A54B3BFF02 for ; Wed, 7 May 2014 07:23:17 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id CCB64202DD for ; Wed, 7 May 2014 07:23:16 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 10E21202B8 for ; Wed, 7 May 2014 07:23:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751829AbaEGHXN (ORCPT ); Wed, 7 May 2014 03:23:13 -0400 Received: from mail-ee0-f46.google.com ([74.125.83.46]:44578 "EHLO mail-ee0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751338AbaEGHXM (ORCPT ); Wed, 7 May 2014 03:23:12 -0400 Received: by mail-ee0-f46.google.com with SMTP id t10so374807eei.5 for ; Wed, 07 May 2014 00:23:11 -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=keIPEafevwei4dWrAamsnH0q5RcsPJ4KLVfjz56wxWg=; b=caamj39PyFi0i1wjayk0+g6vX2qiJ72a+tPvv3Mu1kfJeAZcTH7OcsfrB7sgjFlr0B BABQ8Olxu0sohhMft09B8vXNzQpYoVyD1882KCW+ieMBPMSnrLatP1oi3d/y05KoVMXv zfE3diSq8/TAz1x8t4Sz+1XK1LVvoQ8ESceKlH33DbTfipdjMaO7XrLUTp7cBBnLS8V7 yiwYOmBuzcxSUszcPd0VuTbxeAt0uMpYUpOVcmk4zigKG4bZgXUYX0UFbS+cd8BjtBHM ptUA4m1cAyQwsNhSHxa6vBdkYGdhxQXIoT0el/Vm4DeRHhTBX2SjE82O6lYq/T2LZh/a pM9g== X-Received: by 10.15.24.201 with SMTP id j49mr13625593eeu.99.1399447391394; Wed, 07 May 2014 00:23:11 -0700 (PDT) Received: from david-tp.localdomain (stgt-4d02c40d.pool.mediaWays.net. [77.2.196.13]) by mx.google.com with ESMTPSA id bc51sm44410492eeb.22.2014.05.07.00.23.09 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 07 May 2014 00:23:10 -0700 (PDT) From: David Herrmann To: linux-wireless@vger.kernel.org Cc: "Luis R. Rodriguez" , Jouni Malinen , Vasanthakumar Thiagarajan , Senthil Balasubramanian , "John W. Linville" , ath9k-devel@lists.ath9k.org, Oleksij Rempel , David Herrmann Subject: [PATCH] ath9k: fix NULL-deref in hw_per_calibration() for ar9002 Date: Wed, 7 May 2014 09:22:58 +0200 Message-Id: <1399447378-31503-1-git-send-email-dh.herrmann@gmail.com> X-Mailer: git-send-email 1.9.2 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.4 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 ah->caldata may be NULL if no channel is selected. Check for that before accessing it. Signed-off-by: David Herrmann --- Hi This is _definitely_ only a workaround, given that no-one guarantees ah->caldata is freed while we run in hw_per_calibration(). However, this patch fixes serious kernel panics with wifi-P2P on my machine. I'm not sure why ah->caldata can be NULL, but it definitely is. I think the correct fix would be to synchronously stop any running hw-calibration before setting ah->caldata to NULL. I don't know whether/where that is done, so I wrote this small workaround. Thanks David drivers/net/wireless/ath/ath9k/ar9002_calib.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/net/wireless/ath/ath9k/ar9002_calib.c b/drivers/net/wireless/ath/ath9k/ar9002_calib.c index cdc7400..4667ab9 100644 --- a/drivers/net/wireless/ath/ath9k/ar9002_calib.c +++ b/drivers/net/wireless/ath/ath9k/ar9002_calib.c @@ -99,14 +99,16 @@ static bool ar9002_hw_per_calibration(struct ath_hw *ah, } currCal->calData->calPostProc(ah, numChains); - caldata->CalValid |= currCal->calData->calType; + if (caldata) + caldata->CalValid |= currCal->calData->calType; + currCal->calState = CAL_DONE; iscaldone = true; } else { ar9002_hw_setup_calibration(ah, currCal); } } - } else if (!(caldata->CalValid & currCal->calData->calType)) { + } else if (caldata && !(caldata->CalValid & currCal->calData->calType)) { ath9k_hw_reset_calibration(ah, currCal); }