Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp1995328pxb; Sat, 7 Nov 2020 05:51:53 -0800 (PST) X-Google-Smtp-Source: ABdhPJzASDG+AKs1bR1Gsk2Mplk4dqjOlVeUXmtXf8quSp7HphnJS4J5t/QEQk+tSO9f/fe5u2PL X-Received: by 2002:a50:bb66:: with SMTP id y93mr7011185ede.244.1604757113042; Sat, 07 Nov 2020 05:51:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1604757113; cv=none; d=google.com; s=arc-20160816; b=CTT+Fx7uLxK7wgP/fDnDnxqXQK3PVAi14tX9kVondw9zBo06XQJPCe/moBUjz6CB3U Z/UV1IJYzm/YTEs/DzwpY5FOGbma6MMcX1cs/VdIhQ0ayt0KxFrQ7g+qmvYONEpS09Fw jsOpPH8RF50aVP3IMcfip7Ign1UPrMNLd2Yd7jOpo5nNLqVAXZiR9bI46VdFmtuFoZAj jfXfoyYviJa2ul8hvXcJPkmv/PINcL9+v0+vTD3BvXybQYNB3yBiz27cHuvUFbEhB8ZV sQBXDZ+MiuV8vXY5UkACUih4FjplR3dgvaNHYA0/CRo/2SlgO3pobq/DIJ0SCtePIBsI uVpw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:date:from:dkim-signature; bh=nj2JtUJmFHpe07y5jjEoZy68QUQ8AyUEQF5EdLJkofs=; b=XVvTG5WJmZDcz7e0d+AQadOYoJDKGCAGLHvSG80m+iFS9difopc8mZZdCiIGhAZX9I y1gUzHWtIRyuleAfAJ2kiwLaEJu6NtijCZwLnZ+yicYkXXyB/z1/0p6JW7LJ2mj93uhp 5CmCQ0QI3N4jFhjP0RhVYTPw0a7sbAmAOpShsP9Pth6JmOxuPNB6oBJRl7VgSnTzJm7J MtVk/FM+HEZNlwJL43AKomPypkEltSHmRmYnqfUxhEEUC6SApkwxLFX9SB8g49KiAaud xcVJoR6fOOKU/Qt3/Pp5m6cElHt6g6ESWykKf9Y4NFNTjqUcJkzeqiSmHfr3zG+dR1nn L7jA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=scINATIm; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id d4si3476463edo.178.2020.11.07.05.51.16; Sat, 07 Nov 2020 05:51:53 -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; dkim=pass header.i=@gmail.com header.s=20161025 header.b=scINATIm; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728090AbgKGNuA (ORCPT + 99 others); Sat, 7 Nov 2020 08:50:00 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35552 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727084AbgKGNuA (ORCPT ); Sat, 7 Nov 2020 08:50:00 -0500 Received: from mail-wr1-x444.google.com (mail-wr1-x444.google.com [IPv6:2a00:1450:4864:20::444]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C877FC0613CF; Sat, 7 Nov 2020 05:49:58 -0800 (PST) Received: by mail-wr1-x444.google.com with SMTP id 33so4148382wrl.7; Sat, 07 Nov 2020 05:49:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:date:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=nj2JtUJmFHpe07y5jjEoZy68QUQ8AyUEQF5EdLJkofs=; b=scINATImyjbFT1SRMBhtHASoe4YFJRjQcBST+6yUDQHA36PpkoNUy4b/BDp1peHr/G YjN4m5kJLrFC/y/od3zdzTGF8jZwHFR2L6NAxdTOFE4JKixqX/Sew6lMbiCLy+9cwlXm cSRq/XfZ0miuOY/pCM7/sXx+LYyNaVEYigqVqmGptMvpR3h7cj3arCouluKGGps59laS sn1o0X6/F8eF+haM0AuMiIK4UNuyRTu7PklYhl1WlfzxPG3pNv+72mKY1BbX6obNmo1Y 1isF9S3HYDYKTo6g0NBuVs0dZFylLn0inUXR7fGGewaoAvzBKE/Arzt7luOcuRWqGFtk /Jow== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:date:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=nj2JtUJmFHpe07y5jjEoZy68QUQ8AyUEQF5EdLJkofs=; b=qLbx6zhIyWWysHqNhIStU+yS5SpuvBUwvS+3Q8gwKs5VpeiCJIOz0QxfHEnDaXSj2F iwzkszCJXLqt/NZvrYhkTi8v1lHPyJtJgDP5Z9N73rralkayWLSISbUqIRQzeGvKrqx3 1Zi9MIpOgMueHCyZLmcbEFQMGzMpFdTu4AnQGVkOrnIbFIZN8XRIXMSPOz8WXcdov07T dyGAGCcpZSAJywKRDp9IwUL1G5FWpFn4f4+fOCfLvYheecMUQczutOPHyw2xwqBgNrBH BZiWJ5UIY9EnZOm6g89yfX31aSCGT9xKh3Fx7j1NJfMi4yT5D1pGqmedlN+l3/HCyiGk I8Xw== X-Gm-Message-State: AOAM532VhTOivBSkvhXjl2sTQ3kS1VR9ulXlB/UjRAVXwIeUQiqaP9qO 8ykseaP4hahOavsA9B7UB5g= X-Received: by 2002:a5d:6cc5:: with SMTP id c5mr6971236wrc.301.1604756997485; Sat, 07 Nov 2020 05:49:57 -0800 (PST) Received: from medion (cpc83661-brig20-2-0-cust443.3-3.cable.virginm.net. [82.28.105.188]) by smtp.gmail.com with ESMTPSA id k81sm8117722wma.2.2020.11.07.05.49.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 07 Nov 2020 05:49:56 -0800 (PST) From: Alex Dewar X-Google-Original-From: Alex Dewar Date: Sat, 7 Nov 2020 13:49:08 +0000 To: Kalle Valo Cc: Alex Dewar , netdev@vger.kernel.org, Carl Huang , linux-wireless@vger.kernel.org, linux-kernel@vger.kernel.org, "David S. Miller" , ath11k@lists.infradead.org, Jakub Kicinski Subject: Re: [PATCH 2/2] ath11k: Handle errors if peer creation fails Message-ID: <20201107134908.ncne6nm7yyibp3qt@medion> References: <20201004100218.311653-1-alex.dewar90@gmail.com> <87blhfbysb.fsf@codeaurora.org> <20201006081321.e2tf5xrdhnk4j3nq@medion> <87pn4pfm19.fsf@codeaurora.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <87pn4pfm19.fsf@codeaurora.org> Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org On Sat, Nov 07, 2020 at 01:23:30PM +0200, Kalle Valo wrote: > Alex Dewar writes: > > > On Tue, Oct 06, 2020 at 10:26:28AM +0300, Kalle Valo wrote: > >> Alex Dewar writes: > >> > >> > ath11k_peer_create() is called without its return value being checked, > >> > meaning errors will be unhandled. Add missing check and, as the mutex is > >> > unconditionally unlocked on leaving this function, simplify the exit > >> > path. > >> > > >> > Addresses-Coverity-ID: 1497531 ("Code maintainability issues") > >> > Fixes: 701e48a43e15 ("ath11k: add packet log support for QCA6390") > >> > Signed-off-by: Alex Dewar > >> > --- > >> > drivers/net/wireless/ath/ath11k/mac.c | 21 +++++++++------------ > >> > 1 file changed, 9 insertions(+), 12 deletions(-) > >> > > >> > diff --git a/drivers/net/wireless/ath/ath11k/mac.c b/drivers/net/wireless/ath/ath11k/mac.c > >> > index 7f8dd47d2333..58db1b57b941 100644 > >> > --- a/drivers/net/wireless/ath/ath11k/mac.c > >> > +++ b/drivers/net/wireless/ath/ath11k/mac.c > >> > @@ -5211,7 +5211,7 @@ ath11k_mac_op_assign_vif_chanctx(struct ieee80211_hw *hw, > >> > struct ath11k *ar = hw->priv; > >> > struct ath11k_base *ab = ar->ab; > >> > struct ath11k_vif *arvif = (void *)vif->drv_priv; > >> > - int ret; > >> > + int ret = 0; > >> > >> I prefer not to initialise the ret variable. > >> > >> > arvif->is_started = true; > >> > > >> > /* TODO: Setup ps and cts/rts protection */ > >> > > >> > - mutex_unlock(&ar->conf_mutex); > >> > - > >> > - return 0; > >> > - > >> > -err: > >> > +unlock: > >> > mutex_unlock(&ar->conf_mutex); > >> > > >> > return ret; > >> > >> So in the pending branch I changed this to: > >> > >> ret = 0; > >> > >> out: > >> mutex_unlock(&ar->conf_mutex); > >> > >> return ret; > >> > >> Please check. > > > > I'm afraid you've introduced a bug ;). The body of the first if-statement > > in the function doesn't set ret because no error has occurred. So now > > it'll jump to the label and the function will return ret uninitialized. > > Ouch, so I did. Good catch! I would have hoped that GCC warns about that > but it didn't. > > I fixed the bug and added also a warning messages if peer_create() > fails: > > https://git.kernel.org/pub/scm/linux/kernel/git/kvalo/ath.git/commit/?h=pending&id=e3e7b8072fa6bb0928b9066cf76e19e6bd2ec663 > > Does this look better now? :) LGTM! > > > With the gcc extension, ret will be initialised to zero anyway, so we're > > not saving anything by explicitly assigning to ret later in the > > function. > > I prefer not to initialise ret in the beginning of the function and I > try to maintain that style in ath11k. I think it's more readable that > the error value is assigned just before the goto. Fair enough. I appreciate that it's a style issue. > > -- > https://patchwork.kernel.org/project/linux-wireless/list/ > > https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches