Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp1123453pxb; Thu, 4 Feb 2021 05:48:30 -0800 (PST) X-Google-Smtp-Source: ABdhPJwMiqsFvUoqVPJ/vJZWaQZVZafTwANOMfA86aWv8PGzTTuRdWTtNwrx64xTX0qOI4qzo3xj X-Received: by 2002:a05:6402:1051:: with SMTP id e17mr8107137edu.245.1612446509814; Thu, 04 Feb 2021 05:48:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612446509; cv=none; d=google.com; s=arc-20160816; b=dOaMke14eEjA8iziwHJOGXwKVWBcCSWn5WygH4r/u3ReUN9yByXgLCP3NP+z4+0d28 pFctlCKxo5h8RszsFFHX+fUERbOGs/c+CzdsVUpXfoFJER19XZH3GJPkOj/DFFWDCvc9 ntXFfeSXxtci4TfA0pIsCdtMDZafBJV+2cpPzRVkxqAIrOTgcTj2pbYb6tqPvrWDeuO1 emnSxvBBMIJZjh3HIOpZOK1dPJ6+GOXfmm5R2TEdIFN2MrK9SIwfrZpo0DqReGyS6f0l dygxKKGhZbeHzU9LoTjAqoM+VNHMIdqjjg5OsQb89GIp+qxeh8sPPPHXTOX1amBPYTMf VGuw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:subject:content-transfer-encoding:mime-version :message-id:date:cc:to:from; bh=QX/GKkNaKOYFAMeRYlwnzO5hyU0FR2SamZalQvekVec=; b=E350K6KuT/Icq/raYoKzQ10beL8m/zGmVt5cogK7PZFLmlJdhhdvOlM3rZMe03CirU K45JSu+Wt8kATTK2R2wNxbDnkrhjWDnvsHjoL6wXL0IiuymtzMvy8xBHC8CtKpEy0iUu wrTfqD7c7v3wn2PuBf0W3ncc6HRx4Ov9dJXSYI3BwVX4P57O6DpwwiY3/VzbQ5RB2hnz kn16mLf3g1IOH7TR8vS1qgi5YZjncoj1Rz7HozYq9SCp3NsWPxNKqQCduaQ2YpqOwGTC IKwVJ3W6u4JG/UQXMRTyBbY54CdpE+VVOvwcfjIj6/PdtLwDz6enMfxzVdqf+yQD6l0m 5bXQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id o19si3487907edz.565.2021.02.04.05.48.03; Thu, 04 Feb 2021 05:48:29 -0800 (PST) Received-SPF: pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236446AbhBDNqV (ORCPT + 99 others); Thu, 4 Feb 2021 08:46:21 -0500 Received: from paleale.coelho.fi ([176.9.41.70]:43658 "EHLO farmhouse.coelho.fi" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S236440AbhBDNpn (ORCPT ); Thu, 4 Feb 2021 08:45:43 -0500 Received: from 91-156-6-193.elisa-laajakaista.fi ([91.156.6.193] helo=redipa.ger.corp.intel.com) by farmhouse.coelho.fi with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.93) (envelope-from ) id 1l7ew4-0044Fb-68; Thu, 04 Feb 2021 15:44:40 +0200 From: Luca Coelho To: johannes@sipsolutions.net Cc: linux-wireless@vger.kernel.org Date: Thu, 4 Feb 2021 15:44:39 +0200 Message-Id: X-Mailer: git-send-email 2.30.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on farmhouse.coelho.fi X-Spam-Level: X-Spam-Status: No, score=-2.9 required=5.0 tests=ALL_TRUSTED,BAYES_00, TVD_RCVD_IP autolearn=ham autolearn_force=no version=3.4.4 Subject: [PATCH] cfg80211: initialize reg_rule in __freq_reg_info() Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org From: Luca Coelho Sparse started warning on this function because we can potentially return an uninitialized value. The reason is that if the caller passes a min_bw value that is higher then the last value in bws[], we will not go into the loop and reg_rule will remain initialized. This cannot happen because the only caller of this function uses either 1 or 20 in min_bw, but the function will be more robust if we pre-initialize the value. Signed-off-by: Luca Coelho --- net/wireless/reg.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/wireless/reg.c b/net/wireless/reg.c index 452b698f42be..21536c48deec 100644 --- a/net/wireless/reg.c +++ b/net/wireless/reg.c @@ -1629,7 +1629,7 @@ __freq_reg_info(struct wiphy *wiphy, u32 center_freq, u32 min_bw) { const struct ieee80211_regdomain *regd = reg_get_regdomain(wiphy); static const u32 bws[] = {0, 1, 2, 4, 5, 8, 10, 16, 20}; - const struct ieee80211_reg_rule *reg_rule; + const struct ieee80211_reg_rule *reg_rule = ERR_PTR(-ERANGE); int i = ARRAY_SIZE(bws) - 1; u32 bw; -- 2.30.0