Skip to content

Commit 26fd962

Browse files
kengiterdavem330
authored andcommitted
niu: fix missing checks of niu_pci_eeprom_read
niu_pci_eeprom_read() may fail, so we should check its return value before using the read data. Signed-off-by: Kangjie Lu <kjlu@umn.edu> Acked-by: Shannon Nelson <shannon.lee.nelson@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent ca19fcb commit 26fd962

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

  • drivers/net/ethernet/sun

‎drivers/net/ethernet/sun/niu.c‎

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8100,6 +8100,8 @@ static int niu_pci_vpd_scan_props(struct niu *np, u32 start, u32 end)
81008100
start += 3;
81018101

81028102
prop_len = niu_pci_eeprom_read(np, start + 4);
8103+
if (prop_len < 0)
8104+
return prop_len;
81038105
err = niu_pci_vpd_get_propname(np, start + 5, namebuf, 64);
81048106
if (err < 0)
81058107
return err;
@@ -8144,8 +8146,12 @@ static int niu_pci_vpd_scan_props(struct niu *np, u32 start, u32 end)
81448146
netif_printk(np, probe, KERN_DEBUG, np->dev,
81458147
"VPD_SCAN: Reading in property [%s] len[%d]\n",
81468148
namebuf, prop_len);
8147-
for (i = 0; i < prop_len; i++)
8148-
*prop_buf++ = niu_pci_eeprom_read(np, off + i);
8149+
for (i = 0; i < prop_len; i++) {
8150+
err = niu_pci_eeprom_read(np, off + i);
8151+
if (err >= 0)
8152+
*prop_buf = err;
8153+
++prop_buf;
8154+
}
81498155
}
81508156

81518157
start += len;

0 commit comments

Comments
 (0)