public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Kalle Valo <kvalo@kernel.org>
To: Jeff Johnson <quic_jjohnson@quicinc.com>
Cc: "Gustavo A. R. Silva" <gustavoars@kernel.org>,
	 Jeff Johnson <jjohnson@kernel.org>,
	 <linux-wireless@vger.kernel.org>, <ath11k@lists.infradead.org>,
	 <linux-kernel@vger.kernel.org>,
	<linux-hardening@vger.kernel.org>
Subject: Re: [PATCH][next] wifi: ath11k: Avoid -Wflex-array-member-not-at-end warnings
Date: Thu, 22 Aug 2024 19:50:09 +0300	[thread overview]
Message-ID: <871q2gwlha.fsf@kernel.org> (raw)
In-Reply-To: <8d31adac-fd43-4cf9-8fc8-655b359a573c@quicinc.com> (Jeff Johnson's message of "Fri, 9 Aug 2024 19:21:10 -0700")

Jeff Johnson <quic_jjohnson@quicinc.com> writes:

> On 8/9/2024 9:20 AM, Gustavo A. R. Silva wrote:
>
>> -Wflex-array-member-not-at-end was introduced in GCC-14, and we are
>> getting ready to enable it, globally.
>> 
>> Move the conflicting declaration to the end of the structure. Notice
>> that `struct ieee80211_chanctx_conf` is a flexible structure --a
>> structure that contains a flexible-array member.
>> 
>> Also, remove a couple of unused structures.
>> 
>> Fix the following warnings:
>> drivers/net/wireless/ath/ath11k/core.h:409:39: warning: structure containing a flexible array member is not at the end of another structure [-Wflex-array-member-not-at-end]
>> drivers/net/wireless/ath/ath11k/dp.h:1309:24: warning: structure containing a flexible array member is not at the end of another structure [-Wflex-array-member-not-at-end]
>> drivers/net/wireless/ath/ath11k/dp.h:1368:24: warning: structure containing a flexible array member is not at the end of another structure [-Wflex-array-member-not-at-end]
>> 
>> Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
>> ---
>>  drivers/net/wireless/ath/ath11k/core.h |  4 +++-
>>  drivers/net/wireless/ath/ath11k/dp.h   | 23 -----------------------
>>  2 files changed, 3 insertions(+), 24 deletions(-)
>> 
>> diff --git a/drivers/net/wireless/ath/ath11k/core.h b/drivers/net/wireless/ath/ath11k/core.h
>> index df24f0e409af..e283415dccf3 100644
>> --- a/drivers/net/wireless/ath/ath11k/core.h
>> +++ b/drivers/net/wireless/ath/ath11k/core.h
>> @@ -406,11 +406,13 @@ struct ath11k_vif {
>>  	bool wpaie_present;
>>  	bool bcca_zero_sent;
>>  	bool do_not_send_tmpl;
>> -	struct ieee80211_chanctx_conf chanctx;
>>  	struct ath11k_arp_ns_offload arp_ns_offload;
>>  	struct ath11k_rekey_data rekey_data;
>>  
>>  	struct ath11k_reg_tpc_power_info reg_tpc_info;
>> +
>> +	/* Must be last - ends in a flexible-array member. */
>> +	struct ieee80211_chanctx_conf chanctx;
>
> there is something illogical about this since the vif is allocated using
> sizeof() and hence there will never be memory allocated for the flexible
> array, and it is assigned using either struct assignment or memcpy using the
> struct size which (fortunately) would not transfer the flexible array contents:
> 		arvif->chanctx = *ctx;
>
> 		memcpy(&arvif->chanctx, ctx, sizeof(*ctx));
>
> since ath11k doesn't actually use the drv_priv[] I guess this change is OK, it
> is just strange to me.
>
> also makes me wonder why ath11k keeps a copy of the chanctx instead of just
> getting it from the underlying ieee80211_link_data. but that is outside the
> scope of this discussion.

Yeah, this doesn't look right. I don't think a driver should be copying
struct ieee80211_chanctx_conf like that. I think I'll add a comment
about this to the code:

/* FIXME: Driver should not copy struct ieee80211_chanctx_conf,
 * especially because it has a flexible array. Find a better way.
 */

Thoughts?

-- 
https://patchwork.kernel.org/project/linux-wireless/list/

https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches
https://docs.kernel.org/process/submitting-patches.html

  parent reply	other threads:[~2024-08-22 16:50 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-08-09 16:20 [PATCH][next] wifi: ath11k: Avoid -Wflex-array-member-not-at-end warnings Gustavo A. R. Silva
2024-08-10  2:21 ` Jeff Johnson
2024-08-10 15:41   ` Gustavo A. R. Silva
2024-08-22 16:50   ` Kalle Valo [this message]
2024-09-05 16:20 ` Kalle Valo

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=871q2gwlha.fsf@kernel.org \
    --to=kvalo@kernel.org \
    --cc=ath11k@lists.infradead.org \
    --cc=gustavoars@kernel.org \
    --cc=jjohnson@kernel.org \
    --cc=linux-hardening@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-wireless@vger.kernel.org \
    --cc=quic_jjohnson@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