From patchwork Wed Jan 15 18:41:41 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrea Merello X-Patchwork-Id: 3493091 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 C2440C02DC for ; Wed, 15 Jan 2014 18:41:48 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id B1E2020148 for ; Wed, 15 Jan 2014 18:41:47 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 82C982011D for ; Wed, 15 Jan 2014 18:41:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752549AbaAOSlo (ORCPT ); Wed, 15 Jan 2014 13:41:44 -0500 Received: from mail-wg0-f49.google.com ([74.125.82.49]:51616 "EHLO mail-wg0-f49.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752216AbaAOSln (ORCPT ); Wed, 15 Jan 2014 13:41:43 -0500 Received: by mail-wg0-f49.google.com with SMTP id a1so2135773wgh.28 for ; Wed, 15 Jan 2014 10:41:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:reply-to:in-reply-to:references:date:message-id :subject:from:to:cc:content-type; bh=LbKc8obzspmOOwUQR/La89yky84j++5/KdQMuNnxRlQ=; b=yIH/x1zLt94pY7yvCWhmRiIV0DsQ99xT1PSOJLASvamDmBLp9dT/JaUzIL8O5tCHs4 /sH98lF1zh/pGfE7gBjj21bYGUFSq6kdmtIVWQGnKJ/8axOwuDGauk7gAxjnXuyW7MYw ai2Krudjm2NQqSCM/2KEnTcW52Olj12xK0Rxe7+DNHgF9yKHTNOAr1Ja16uB08eNngH3 sj9hpnXePF2iocfWM1OZNpDN5Jp8479A43TWNFJDerSz0pNffNBqjnFgD63gGWA+CcIG Vj5l/eEzav5WefDCfhx7QCQWNo5JCrGu9s3dguDAH6vXY4lmu4ka6gMMF/WsQi2oxhyg 1cTg== MIME-Version: 1.0 X-Received: by 10.194.178.135 with SMTP id cy7mr4009274wjc.21.1389811301709; Wed, 15 Jan 2014 10:41:41 -0800 (PST) Received: by 10.216.106.15 with HTTP; Wed, 15 Jan 2014 10:41:41 -0800 (PST) Reply-To: andrea.merello@gmail.com In-Reply-To: <52D6C871.7020302@lwfinger.net> References: <522F584E.6000806@lwfinger.net> <52D6B31F.8080007@lwfinger.net> <52D6C871.7020302@lwfinger.net> Date: Wed, 15 Jan 2014 19:41:41 +0100 Message-ID: Subject: Re: RTL8187SE staging Linux driver From: Andrea Merello To: Larry Finger Cc: Bernhard Schiffner , John Linville , Greg Kroah-Hartman , linux-wireless@vger.kernel.org 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.1 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 Thank you. The driver tries to set this in rtl8180_probe, line 2140 dev->max_signal = 65; I have no idea yet if this will be overwritten somewhere other or whatever else.. In this case maybe the value become corrupted later on, after mac80211 initialization, BTW, what about making mac80211 robust to at least wrong initialization? Simulating a initialization to zero, the following patch will triggers also lot of other WARN_ON because of broken signal information, but should avoid the panic.. BTW Currently i'm not able to reproduce the rtl8187se bug anymore :( From cdc000007a1226b9daaab2d8354aab55127c1fb4 Mon Sep 17 00:00:00 2001 From: andrea merello Date: Wed, 15 Jan 2014 19:17:25 +0100 Subject: [PATCH] MAC80211: Issue a WARN and prevent divide by zero when max_signal is not set if the driver sets IEEE80211_HW_SIGNAL_UNSPEC, then mac80211 tries to perform a division by max_signal while scanning. Print a warn and set a dummy value. This should result is wrong signal information but avoid a crash. --- net/mac80211/main.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/net/mac80211/main.c b/net/mac80211/main.c index d767cfb..449c417 100644 --- a/net/mac80211/main.c +++ b/net/mac80211/main.c @@ -753,6 +753,11 @@ int ieee80211_register_hw(struct ieee80211_hw *hw) netdev_features_t feature_whitelist; struct cfg80211_chan_def dflt_chandef = {}; + if (WARN((hw->flags & IEEE80211_HW_SIGNAL_UNSPEC) && + (hw->max_signal < 0), + "max_signal not set while set IEEE80211_HW_SIGNAL_UNSPEC\n")) + hw->max_signal = 1; + if (hw->flags & IEEE80211_HW_QUEUE_CONTROL && (local->hw.offchannel_tx_hw_queue == IEEE80211_INVAL_HW_QUEUE || local->hw.offchannel_tx_hw_queue >= local->hw.queues))