[PATCH] scsi: wd719x: initialize all fields of eeprom_93cx6 struct

stf_xl@wp.pl posted 1 patch 13 hours ago
drivers/scsi/wd719x.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
[PATCH] scsi: wd719x: initialize all fields of eeprom_93cx6 struct
Posted by stf_xl@wp.pl 13 hours ago
From: Stanislaw Gruszka <stf_xl@wp.pl>

Commit 7738a7ab9d12 ("misc: eeprom: eeprom_93cx6: Add quirk for extra
read clock cycle") added extra 'quirk' field to struct eeprom_93cx6,
which change how the data is read.

Some existing users of eeprom_93cx6, including wd719x driver, allocate
the structure on the stack without initialization of all the fields.
As a result, the added quirk field has undefined value, what can
randomly cause reading wrong data from the EEPROM.

Fix by using designated initialization.

Fixes: 7738a7ab9d12 ("misc: eeprom: eeprom_93cx6: Add quirk for extra read clock cycle")
Cc: stable@kernel.org # v6.13+
Signed-off-by: Stanislaw Gruszka <stf_xl@wp.pl>
---
 drivers/scsi/wd719x.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/scsi/wd719x.c b/drivers/scsi/wd719x.c
index 830d40f57f6a..2bdfb2c759ed 100644
--- a/drivers/scsi/wd719x.c
+++ b/drivers/scsi/wd719x.c
@@ -739,15 +739,15 @@ static void wd719x_eeprom_reg_write(struct eeprom_93cx6 *eeprom)
 /* read config from EEPROM so it can be downloaded by the RISC on (re-)init */
 static void wd719x_read_eeprom(struct wd719x *wd)
 {
-	struct eeprom_93cx6 eeprom;
+	struct eeprom_93cx6 eeprom = {
+		.data = wd,
+		.register_read = wd719x_eeprom_reg_read,
+		.register_write = wd719x_eeprom_reg_write,
+		.width = PCI_EEPROM_WIDTH_93C46,
+	};
 	u8 gpio;
 	struct wd719x_eeprom_header header;
 
-	eeprom.data = wd;
-	eeprom.register_read = wd719x_eeprom_reg_read;
-	eeprom.register_write = wd719x_eeprom_reg_write;
-	eeprom.width = PCI_EEPROM_WIDTH_93C46;
-
 	/* set all outputs to low */
 	wd719x_writeb(wd, WD719X_PCI_GPIO_DATA, 0);
 	/* configure GPIO pins */
-- 
2.50.1