From: Nathan Chancellor <natechancellor@gmail.com>
To: Jerome Pouiller <Jerome.Pouiller@silabs.com>
Cc: devel@driverdev.osuosl.org, netdev@vger.kernel.org,
linux-wireless@vger.kernel.org, linux-kernel@vger.kernel.org,
Dan Carpenter <dan.carpenter@oracle.com>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
"David S . Miller" <davem@davemloft.net>,
Kalle Valo <kvalo@codeaurora.org>
Subject: Re: [PATCH 8/8] staging: wfx: improve robustness of wfx_get_hw_rate()
Date: Thu, 15 Oct 2020 18:50:34 -0700 [thread overview]
Message-ID: <20201016015034.GA2122229@ubuntu-m3-large-x86> (raw)
In-Reply-To: <20201009171307.864608-9-Jerome.Pouiller@silabs.com>
On Fri, Oct 09, 2020 at 07:13:07PM +0200, Jerome Pouiller wrote:
> From: Jérôme Pouiller <jerome.pouiller@silabs.com>
>
> Smatch complains:
>
> data_tx.c:37 wfx_get_hw_rate() warn: constraint '(struct ieee80211_supported_band)->bitrates' overflow 'band->bitrates' 0 <= abs_rl '0-127' user_rl '' required = '(struct ieee80211_supported_band)->n_bitrates'
> 23 struct ieee80211_supported_band *band;
> 24
> 25 if (rate->idx < 0)
> 26 return -1;
> 27 if (rate->flags & IEEE80211_TX_RC_MCS) {
> 28 if (rate->idx > 7) {
> 29 WARN(1, "wrong rate->idx value: %d", rate->idx);
> 30 return -1;
> 31 }
> 32 return rate->idx + 14;
> 33 }
> 34 // WFx only support 2GHz, else band information should be retrieved
> 35 // from ieee80211_tx_info
> 36 band = wdev->hw->wiphy->bands[NL80211_BAND_2GHZ];
> 37 return band->bitrates[rate->idx].hw_value;
>
> Add a simple check to make Smatch happy.
>
> Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
> Signed-off-by: Jérôme Pouiller <jerome.pouiller@silabs.com>
> ---
> drivers/staging/wfx/data_tx.c | 4 ++++
> 1 file changed, 4 insertions(+)
>
> diff --git a/drivers/staging/wfx/data_tx.c b/drivers/staging/wfx/data_tx.c
> index 8db0be08daf8..41f6a604a697 100644
> --- a/drivers/staging/wfx/data_tx.c
> +++ b/drivers/staging/wfx/data_tx.c
> @@ -31,6 +31,10 @@ static int wfx_get_hw_rate(struct wfx_dev *wdev,
> }
> return rate->idx + 14;
> }
> + if (rate->idx >= band->n_bitrates) {
> + WARN(1, "wrong rate->idx value: %d", rate->idx);
> + return -1;
> + }
> // WFx only support 2GHz, else band information should be retrieved
> // from ieee80211_tx_info
> band = wdev->hw->wiphy->bands[NL80211_BAND_2GHZ];
> --
> 2.28.0
>
This now causes a clang warning:
drivers/staging/wfx/data_tx.c:34:19: warning: variable 'band' is uninitialized when used here [-Wuninitialized]
if (rate->idx >= band->n_bitrates) {
^~~~
drivers/staging/wfx/data_tx.c:23:39: note: initialize the variable 'band' to silence this warning
struct ieee80211_supported_band *band;
^
= NULL
1 warning generated.
Cheers,
Nathan
_______________________________________________
devel mailing list
devel@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
prev parent reply other threads:[~2020-10-16 1:50 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-10-09 17:12 [PATCH 0/8] staging: wfx: fix issues reported by Smatch Jerome Pouiller
2020-10-09 17:13 ` [PATCH 1/8] staging: wfx: improve error handling of hif_join() Jerome Pouiller
2020-10-09 17:13 ` [PATCH 2/8] staging: wfx: check memory allocation Jerome Pouiller
2020-10-09 18:51 ` Kalle Valo
2020-10-10 12:07 ` Jérôme Pouiller
2020-10-10 13:18 ` Dan Carpenter
2020-10-10 13:54 ` Dan Carpenter
2020-10-09 17:13 ` [PATCH 3/8] staging: wfx: standardize the error when vif does not exist Jerome Pouiller
2020-10-09 18:52 ` Kalle Valo
2020-10-10 12:22 ` Jérôme Pouiller
2020-10-10 12:40 ` Greg Kroah-Hartman
2020-10-10 13:29 ` Jérôme Pouiller
2020-10-09 17:13 ` [PATCH 4/8] staging: wfx: wfx_init_common() returns NULL on error Jerome Pouiller
2020-10-09 17:13 ` [PATCH 5/8] staging: wfx: increase robustness of hif_generic_confirm() Jerome Pouiller
2020-10-09 17:13 ` [PATCH 6/8] staging: wfx: gpiod_get_value() can return an error Jerome Pouiller
2020-10-09 17:13 ` [PATCH 7/8] staging: wfx: drop unicode characters from strings Jerome Pouiller
2020-10-09 17:13 ` [PATCH 8/8] staging: wfx: improve robustness of wfx_get_hw_rate() Jerome Pouiller
2020-10-16 1:50 ` Nathan Chancellor [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=20201016015034.GA2122229@ubuntu-m3-large-x86 \
--to=natechancellor@gmail.com \
--cc=Jerome.Pouiller@silabs.com \
--cc=dan.carpenter@oracle.com \
--cc=davem@davemloft.net \
--cc=devel@driverdev.osuosl.org \
--cc=gregkh@linuxfoundation.org \
--cc=kvalo@codeaurora.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-wireless@vger.kernel.org \
--cc=netdev@vger.kernel.org \
/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;
as well as URLs for NNTP newsgroup(s).