Skip to contentSkip to conversation

wifi: rtl818x: initialize eeprom_93cx6 struct to zero

PATCH In review [email protected] 2 participants 3 messages Jul 23 – Jul 30

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 wifi: rtl818x: initialize eeprom_93cx6 struct to zero

From: Stanislaw Gruszka <[email protected]>

Commit 7738a7ab9d12 ("misc: eeprom: eeprom_93cx6: Add quirk for extra read clock cycle") added extra 'quirk' field to struct eeprom_93cx6.

Many existing users of eeprom_93cx6, including rtl818x drivers, allocate the structure on the stack without initializing all fields. As a result, the added quirk field has an undefined value and can randomly cause reading wrong data from the EEPROM.

Fix by initializing the structures with {}.

Fixes 7738a7ab9d12 ("misc: eeprom: eeprom_93cx6: Add quirk for extra read clock cycle")
Cc [email protected] # v6.13+
---
 drivers/net/wireless/realtek/rtl818x/rtl8180/dev.c | 2 +-
 drivers/net/wireless/realtek/rtl818x/rtl8187/dev.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
drivers/net/wireless/realtek/rtl818x/rtl8180/dev.c +1 -1
index 070c0431c482..4a5989172a5e 100644
@@ -1652,7 +1652,7 @@ static void rtl8180_eeprom_register_write(struct eeprom_93cx6 *eeprom)
 
 static void rtl8180_eeprom_read(struct rtl8180_priv *priv)
 {
-	struct eeprom_93cx6 eeprom;
+	struct eeprom_93cx6 eeprom = {};
 	int eeprom_cck_table_adr;
 	u16 eeprom_val;
 	int i;
drivers/net/wireless/realtek/rtl818x/rtl8187/dev.c +1 -1
index 1d21c468a236..a766712187f7 100644
@@ -1445,7 +1445,7 @@ static int rtl8187_probe(struct usb_interface *intf,
 	struct usb_device *udev = interface_to_usbdev(intf);
 	struct ieee80211_hw *dev;
 	struct rtl8187_priv *priv;
-	struct eeprom_93cx6 eeprom;
+	struct eeprom_93cx6 eeprom = {};
 	struct ieee80211_channel *channel;
 	const char *chip_name;
 	u16 txpwr, reg;
Signature · 1 line
2.50.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 10 lines · [email protected] <[email protected]> wrote:

From: Stanislaw Gruszka <[email protected]>

Commit 7738a7ab9d12 ("misc: eeprom: eeprom_93cx6: Add quirk for extra read clock cycle") added extra 'quirk' field to struct eeprom_93cx6.

Many existing users of eeprom_93cx6, including rtl818x drivers, allocate the structure on the stack without initializing all fields. As a result, the added quirk field has an undefined value and can randomly cause reading wrong data from the EEPROM.

Quoted 5 lines

Fix by initializing the structures with {}.

Fixes 7738a7ab9d12 ("misc: eeprom: eeprom_93cx6: Add quirk for extra read clock cycle")
Cc [email protected] # v6.13+
#2 lore raw
In reply to [email protected]
Quoted 10 lines · [email protected] wrote:

From: Stanislaw Gruszka <[email protected]>

Commit 7738a7ab9d12 ("misc: eeprom: eeprom_93cx6: Add quirk for extra read clock cycle") added extra 'quirk' field to struct eeprom_93cx6.

Many existing users of eeprom_93cx6, including rtl818x drivers, allocate the structure on the stack without initializing all fields. As a result, the added quirk field has an undefined value and can randomly cause reading wrong data from the EEPROM.

Quoted 6 lines

Fix by initializing the structures with {}.

Fixes 7738a7ab9d12 ("misc: eeprom: eeprom_93cx6: Add quirk for extra read clock cycle")
Cc [email protected] # v6.13+

1 patch(es) applied to rtw-next branch of rtw.git, thanks.

799b5f45cb81 wifi: rtl818x: initialize eeprom_93cx6 struct to zero

---
https://github.com/pkshih/rtw.git