All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] mt76: avoid uninitialized skb data
@ 2025-08-07 20:52 Arnd Bergmann
  0 siblings, 0 replies; only message in thread
From: Arnd Bergmann @ 2025-08-07 20:52 UTC (permalink / raw)
  To: Felix Fietkau, Lorenzo Bianconi, Ryder Lee, Matthias Brugger,
	AngeloGioacchino Del Regno, Nathan Chancellor
  Cc: Arnd Bergmann, Shayne Chen, Sean Wang, Nick Desaulniers,
	Bill Wendling, Justin Stitt, Peter Chiu, Bo Jiao, Howard Hsu,
	linux-wireless, linux-kernel, linux-arm-kernel, linux-mediatek,
	llvm

From: Arnd Bergmann <arnd@arndb.de>

Two functions in the mt7996 driver cause a clang-21 build warning because
the pass uninitialized data into skb_put_data:

drivers/net/wireless/mediatek/mt76/mt7996/mcu.c:1894:21: error: variable 'hdr' is uninitialized when passed as a const pointer argument here [-Werror,-Wuninitialized-const-pointer]
 1894 |         skb_put_data(skb, &hdr, sizeof(hdr));
      |                            ^~~
drivers/net/wireless/mediatek/mt76/mt7996/mcu.c:3386:21: error: variable 'hdr' is uninitialized when passed as a const pointer argument here [-Werror,-Wuninitialized-const-pointer]
 3386 |         skb_put_data(skb, &hdr, sizeof(hdr));
      |                            ^~~

Remove the otherwise unused variables and instead use skb_put_zero() instead
to fill the header with zeroes.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
 drivers/net/wireless/mediatek/mt76/mt7996/mcu.c | 12 ++++--------
 1 file changed, 4 insertions(+), 8 deletions(-)

diff --git a/drivers/net/wireless/mediatek/mt76/mt7996/mcu.c b/drivers/net/wireless/mediatek/mt76/mt7996/mcu.c
index 3593fd40c51b..6a00df3c5343 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7996/mcu.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7996/mcu.c
@@ -1880,18 +1880,17 @@ int mt7996_mcu_set_fixed_rate_ctrl(struct mt7996_dev *dev,
 				   void *data, u16 version)
 {
 	struct ra_fixed_rate *req;
-	struct uni_header hdr;
 	struct sk_buff *skb;
 	struct tlv *tlv;
 	int len;
 
-	len = sizeof(hdr) + sizeof(*req);
+	len = sizeof(struct uni_header) + sizeof(*req);
 
 	skb = mt76_mcu_msg_alloc(&dev->mt76, NULL, len);
 	if (!skb)
 		return -ENOMEM;
 
-	skb_put_data(skb, &hdr, sizeof(hdr));
+	skb_put_zero(skb, sizeof(struct uni_header));
 
 	tlv = mt7996_mcu_add_uni_tlv(skb, UNI_RA_FIXED_RATE, sizeof(*req));
 	req = (struct ra_fixed_rate *)tlv;
@@ -3370,20 +3369,17 @@ void mt7996_mcu_exit(struct mt7996_dev *dev)
 
 int mt7996_mcu_set_hdr_trans(struct mt7996_dev *dev, bool hdr_trans)
 {
-	struct {
-		u8 __rsv[4];
-	} __packed hdr;
 	struct hdr_trans_blacklist *req_blacklist;
 	struct hdr_trans_en *req_en;
 	struct sk_buff *skb;
 	struct tlv *tlv;
-	int len = MT7996_HDR_TRANS_MAX_SIZE + sizeof(hdr);
+	int len = MT7996_HDR_TRANS_MAX_SIZE + 4;
 
 	skb = mt76_mcu_msg_alloc(&dev->mt76, NULL, len);
 	if (!skb)
 		return -ENOMEM;
 
-	skb_put_data(skb, &hdr, sizeof(hdr));
+	skb_put_zero(skb, 4);
 
 	tlv = mt7996_mcu_add_uni_tlv(skb, UNI_HDR_TRANS_EN, sizeof(*req_en));
 	req_en = (struct hdr_trans_en *)tlv;
-- 
2.39.5



^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2025-08-07 20:56 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-08-07 20:52 [PATCH] mt76: avoid uninitialized skb data Arnd Bergmann

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.