Received: by 2002:a25:824b:0:0:0:0:0 with SMTP id d11csp470034ybn; Thu, 3 Oct 2019 07:41:10 -0700 (PDT) X-Google-Smtp-Source: APXvYqwV3rcEQGHfYOVozxUBFUhB+slcLD2A5ssFj4jBsURPzrMAXMV2XtesA44BK1629v3Zhq/p X-Received: by 2002:a17:906:7d10:: with SMTP id u16mr7952616ejo.194.1570113670613; Thu, 03 Oct 2019 07:41:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570113670; cv=none; d=google.com; s=arc-20160816; b=uJBp6Gflu7vEhBYgPpbDen8m4YkEkHZaKW/Wm/+yCykbd56JwCvpnJgdoxoy3XBVRa l6umeTm1leD2lMb+AaeIOVcns5FzqXs7+HcE7+ujPJXqh6xtW7LkLtVoWxdsY8V7b1Qz PMTICTIpi8uV6qvfFC1x5hFC/nCPuuTZwp/1aQ3vVhKcKQ4+G5WeGa4OjxBMQ/CKgJ1d 7IV4QA2hTJQHj0fprfSWga2JsztYaibkT8N3GkYUusEKlPdPpc9gipHQxnX8hIfjiqz9 sVfLLmoWLZ0fnE00jEM0GqLT/tV92qUN0NxqJ5iOtnm+qchIMm5YVMgT0cnppCSpcPY1 0q0g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:reply-to; bh=RhaZOkcAwmULT8u7N7kowltYRpwtVwSoOJwHBuJuEoY=; b=fOB+EqjqzZTcB+BsEpwnf2fpliSgRtDRFPBqdUdbUCogjjtE/LQh95cRp1Ps/R4Vb3 7innbwPTaVLs/icLrwovk6hdD7n4h/51HUR7mtAix0GByrh3YXEI9ihNrmtnlI0E+mi7 urpPjRYII8TvSEUw6eS69/ZihHlIyJrNCrA85vsn0zs//4x0mtFkjDNPACpAaIOdUlz8 iEv6nBsc/5Y/R1mnaFBndx4kj43C5244lAV7NubcsH0XqLGskGSgbQULF2fOtFLCOk/e EBT/HSHmHqhdWuUn5BnqFoHJOjrlperXSxNK33RSpYCrtNPBaIfJ97d+BbTVxB4z87xZ n7iA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t18si1258935eju.329.2019.10.03.07.40.45; Thu, 03 Oct 2019 07:41:10 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730490AbfJCNju (ORCPT + 99 others); Thu, 3 Oct 2019 09:39:50 -0400 Received: from mail-ed1-f68.google.com ([209.85.208.68]:44973 "EHLO mail-ed1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729440AbfJCNju (ORCPT ); Thu, 3 Oct 2019 09:39:50 -0400 Received: by mail-ed1-f68.google.com with SMTP id r16so2464011edq.11; Thu, 03 Oct 2019 06:39:47 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:reply-to:subject:to:cc:references:from :message-id:date:user-agent:mime-version:in-reply-to :content-language:content-transfer-encoding; bh=RhaZOkcAwmULT8u7N7kowltYRpwtVwSoOJwHBuJuEoY=; b=OFN/uyCG5Dk6Ye+LXVfKF1+fV0EStU24XzH0u+ZPSA4anSkVXHhkSOzfauxhwKztU7 8QLd4krvsv+okyfYwgcwtDj6HdPfZMUEFmySJ67rJLjN6OOLcshMr3Wd+ZIO66sb2p95 WVj85n4i9b0oJV9oZVDZsgflxauIML5S8Sy9COmv0DuwRs4/j6IL+2Tbl3nddIUhuKUh /jEtO6iKltFSFVpY6z1wIq6vSHDVoUy7YT8/kgUsvWYUk85RD3/ECpthj/5AeQCNKGvF mWBI6gu1MkWzIiMVVypRUAzwbGToFrBR4OBQT+bHatawViSDgZRYgAduASFz1iuwDWpW 5dAw== X-Gm-Message-State: APjAAAUjR365i+cJhCBlmDbb8UfSnQKpD7vpDMFBQD8pvgPyhhWy0BWp fs76XSkFcnTDf/hEOGeIJYeJ0nPL X-Received: by 2002:a17:906:944b:: with SMTP id z11mr7507866ejx.46.1570109986998; Thu, 03 Oct 2019 06:39:46 -0700 (PDT) Received: from [10.10.2.174] (bran.ispras.ru. [83.149.199.196]) by smtp.gmail.com with ESMTPSA id y25sm255019eju.39.2019.10.03.06.39.45 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 03 Oct 2019 06:39:46 -0700 (PDT) Reply-To: efremov@linux.com Subject: Re: [PATCH] staging: wlan-ng: fix uninitialized variable To: Dan Carpenter Cc: devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org, Greg Kroah-Hartman , stable@vger.kernel.org References: <20191002174103.1274-1-efremov@linux.com> <20191003112649.GR22609@kadam> From: Denis Efremov Message-ID: Date: Thu, 3 Oct 2019 16:39:45 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.1.0 MIME-Version: 1.0 In-Reply-To: <20191003112649.GR22609@kadam> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, On 10/3/19 2:26 PM, Dan Carpenter wrote: > On Wed, Oct 02, 2019 at 08:41:03PM +0300, Denis Efremov wrote: >> The result variable in prism2_connect() can be used uninitialized on path >> !channel --> ... --> is_wep --> sme->key --> sme->key_idx >= NUM_WEPKEYS. >> This patch initializes result with 0. >> >> Cc: Greg Kroah-Hartman >> Cc: stable@vger.kernel.org >> Signed-off-by: Denis Efremov >> --- >> drivers/staging/wlan-ng/cfg80211.c | 2 +- >> 1 file changed, 1 insertion(+), 1 deletion(-) >> >> diff --git a/drivers/staging/wlan-ng/cfg80211.c b/drivers/staging/wlan-ng/cfg80211.c >> index eee1998c4b18..d426905e187e 100644 >> --- a/drivers/staging/wlan-ng/cfg80211.c >> +++ b/drivers/staging/wlan-ng/cfg80211.c >> @@ -441,7 +441,7 @@ static int prism2_connect(struct wiphy *wiphy, struct net_device *dev, >> int chan = -1; >> int is_wep = (sme->crypto.cipher_group == WLAN_CIPHER_SUITE_WEP40) || >> (sme->crypto.cipher_group == WLAN_CIPHER_SUITE_WEP104); >> - int result; >> + int result = 0; >> int err = 0; >> > > I can't see any reason why we should have both "err" and "result". > Maybe in olden times "result" used to save positive error codes instead > of negative error codes but now it's just negatives and zero on success. > There is no reason for the exit label either, we could just return > directly. > > So could you redo it and get rid of "result" entirely? Otherwise it > just causes more bugs like this. > Yes, of course. I will prepare v2. Thanks, Denis