From: "Berg, Benjamin" <benjamin.berg@intel.com>
To: "kernel-janitors@vger.kernel.org"
<kernel-janitors@vger.kernel.org>,
"Markus.Elfring@web.de" <Markus.Elfring@web.de>,
"davem@davemloft.net" <davem@davemloft.net>,
"Berg, Johannes" <johannes.berg@intel.com>,
"kvalo@kernel.org" <kvalo@kernel.org>,
"quic_srirrama@quicinc.com" <quic_srirrama@quicinc.com>,
"gregory.greenman@intel.com" <gregory.greenman@intel.com>,
"linux-wireless@vger.kernel.org" <linux-wireless@vger.kernel.org>,
"kuba@kernel.org" <kuba@kernel.org>,
"netdev@vger.kernel.org" <netdev@vger.kernel.org>,
"edumazet@google.com" <edumazet@google.com>,
"Korenblit, Miriam Rachel" <miriam.rachel.korenblit@intel.com>,
"pabeni@redhat.com" <pabeni@redhat.com>
Cc: "horms@kernel.org" <horms@kernel.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"cocci@inria.fr" <cocci@inria.fr>
Subject: Re: [PATCH RESEND] iwlwifi: Adjust input parameter validation in iwl_sta_calc_ht_flags()
Date: Mon, 3 Mar 2025 13:46:58 +0000 [thread overview]
Message-ID: <529d640929c2349f2dfe6c3de20331b5b809fcfb.camel@intel.com> (raw)
In-Reply-To: <22e24ec8-283f-49e9-b7b0-555e8113c250@web.de>
On Mon, 2025-03-03 at 14:18 +0100, Markus Elfring wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Wed, 19 Apr 2023 19:19:34 +0200
>
> The address of a data structure member was determined before
> a corresponding null pointer check in the implementation of
> the function “iwl_sta_calc_ht_flags”.
>
> Thus avoid the risk for undefined behaviour by moving the assignment
> for the variable “sta_ht_inf” behind the null pointer check.
I am a bit confused, I don't see any risk of undefined behaviour here.
The change is obviously fine, and I guess one can argue that it is less
confusing as the compiler will generate a warning if one uses the
variable before assignment.
However, the code is both well defined and correct. If sta is NULL then
sta_ht_inf is never used, so the fact that it is effectively a NULL
pointer [offsetof(struct ieee80211_sta, deflink.ht_cap)] does not
matter.
Benjamin
> This issue was detected by using the Coccinelle software.
>
> Fixes: 046d2e7c50e3 ("mac80211: prepare sta handling for MLO
> support")
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
> drivers/net/wireless/intel/iwlwifi/dvm/sta.c | 8 ++++++--
> 1 file changed, 6 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/net/wireless/intel/iwlwifi/dvm/sta.c
> b/drivers/net/wireless/intel/iwlwifi/dvm/sta.c
> index cef43cf80620..74814ce0155e 100644
> --- a/drivers/net/wireless/intel/iwlwifi/dvm/sta.c
> +++ b/drivers/net/wireless/intel/iwlwifi/dvm/sta.c
> @@ -147,7 +147,7 @@ static void iwl_sta_calc_ht_flags(struct iwl_priv
> *priv,
> struct iwl_rxon_context *ctx,
> __le32 *flags, __le32 *mask)
> {
> - struct ieee80211_sta_ht_cap *sta_ht_inf = &sta-
> >deflink.ht_cap;
> + struct ieee80211_sta_ht_cap *sta_ht_inf;
>
> *mask = STA_FLG_RTS_MIMO_PROT_MSK |
> STA_FLG_MIMO_DIS_MSK |
> @@ -156,7 +156,11 @@ static void iwl_sta_calc_ht_flags(struct
> iwl_priv *priv,
> STA_FLG_AGG_MPDU_DENSITY_MSK;
> *flags = 0;
>
> - if (!sta || !sta_ht_inf->ht_supported)
> + if (!sta)
> + return;
> +
> + sta_ht_inf = &sta->deflink.ht_cap;
> + if (!sta_ht_inf->ht_supported)
> return;
>
> IWL_DEBUG_INFO(priv, "STA %pM SM PS mode: %s\n",
> --
> 2.40.0
>
Intel Deutschland GmbH
Registered Address: Am Campeon 10, 85579 Neubiberg, Germany
Tel: +49 89 99 8853-0, www.intel.de
Managing Directors: Sean Fennelly, Jeffrey Schneiderman, Tiffany Doon Silva
Chairperson of the Supervisory Board: Nicole Lau
Registered Office: Munich
Commercial Register: Amtsgericht Muenchen HRB 186928
prev parent reply other threads:[~2025-03-03 13:47 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <40c60719-4bfe-b1a4-ead7-724b84637f55@web.de>
[not found] ` <1a11455f-ab57-dce0-1677-6beb8492a257@web.de>
[not found] ` <d90b8c11-7a40-eec4-007d-3640c0725a56@web.de>
2025-03-03 13:04 ` [PATCH RESEND] iwlegacy: Adjust input parameter validation in il_set_ht_add_station() Markus Elfring
[not found] ` <9cb634c8-d6e6-32bc-5fd6-79bf6b274f96@web.de>
2025-03-03 13:18 ` [PATCH RESEND] iwlwifi: Adjust input parameter validation in iwl_sta_calc_ht_flags() Markus Elfring
2025-03-03 13:46 ` Berg, Benjamin [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=529d640929c2349f2dfe6c3de20331b5b809fcfb.camel@intel.com \
--to=benjamin.berg@intel.com \
--cc=Markus.Elfring@web.de \
--cc=cocci@inria.fr \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=gregory.greenman@intel.com \
--cc=horms@kernel.org \
--cc=johannes.berg@intel.com \
--cc=kernel-janitors@vger.kernel.org \
--cc=kuba@kernel.org \
--cc=kvalo@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-wireless@vger.kernel.org \
--cc=miriam.rachel.korenblit@intel.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=quic_srirrama@quicinc.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