From: Johannes Berg <johannes@sipsolutions.net>
To: trix@redhat.com, davem@davemloft.net, kuba@kernel.org,
nathan@kernel.org, ndesaulniers@google.com,
cjhuang@codeaurora.org, briannorris@chromium.org,
kuabhs@chromium.org
Cc: linux-wireless@vger.kernel.org, netdev@vger.kernel.org,
linux-kernel@vger.kernel.org, llvm@lists.linux.dev
Subject: Re: [PATCH] nl80211: check return of nla_parse_nested
Date: Fri, 18 Feb 2022 17:51:04 +0100 [thread overview]
Message-ID: <cbc4026aa94ff68e984743ef1666a6dd810c596d.camel@sipsolutions.net> (raw)
In-Reply-To: <20220218163045.3370662-1-trix@redhat.com>
On Fri, 2022-02-18 at 08:30 -0800, trix@redhat.com wrote:
> From: Tom Rix <trix@redhat.com>
>
> Clang static analysis reports this representative problem
> nl80211.c:15426:6: warning: Branch condition evaluates
> to a garbage value
> if (!tb[NL80211_SAR_ATTR_TYPE] ||
> ^~~~~~~~~~~~~~~~~~~~~~~~~~
>
> tb is set when nla_parse_nested() is successful.
> So check.
Well, it's a bit annoying that we cannot express/check this, but we
already validated that it's going to succeed, through the nested policy:
static const struct nla_policy nl80211_policy[NUM_NL80211_ATTR] = {
[...]
[NL80211_ATTR_SAR_SPEC] = NLA_POLICY_NESTED(sar_policy),
Thus, it cannot actually fail. I suppose in this case checking for
errors doesn't make the code that much worse, but there's isn't really
much point. Maybe a comment would be useful?
johannes
prev parent reply other threads:[~2022-02-18 16:51 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-02-18 16:30 [PATCH] nl80211: check return of nla_parse_nested trix
2022-02-18 16:51 ` Johannes Berg [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=cbc4026aa94ff68e984743ef1666a6dd810c596d.camel@sipsolutions.net \
--to=johannes@sipsolutions.net \
--cc=briannorris@chromium.org \
--cc=cjhuang@codeaurora.org \
--cc=davem@davemloft.net \
--cc=kuabhs@chromium.org \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-wireless@vger.kernel.org \
--cc=llvm@lists.linux.dev \
--cc=nathan@kernel.org \
--cc=ndesaulniers@google.com \
--cc=netdev@vger.kernel.org \
--cc=trix@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox