Commit ec3bf766 authored by Kangjie Lu's avatar Kangjie Lu Committed by Stefan Bader

niu: fix missing checks of niu_pci_eeprom_read

BugLink: https://bugs.launchpad.net/bugs/1818813

[ Upstream commit 26fd962b ]

niu_pci_eeprom_read() may fail, so we should check its return value
before using the read data.
Signed-off-by: default avatarKangjie Lu <kjlu@umn.edu>
Acked-by: default avatarShannon Nelson <shannon.lee.nelson@gmail.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
Signed-off-by: default avatarJuerg Haefliger <juergh@canonical.com>
Signed-off-by: default avatarKhalid Elmously <khalid.elmously@canonical.com>
parent 60fa1571
...@@ -8121,6 +8121,8 @@ static int niu_pci_vpd_scan_props(struct niu *np, u32 start, u32 end) ...@@ -8121,6 +8121,8 @@ static int niu_pci_vpd_scan_props(struct niu *np, u32 start, u32 end)
start += 3; start += 3;
prop_len = niu_pci_eeprom_read(np, start + 4); prop_len = niu_pci_eeprom_read(np, start + 4);
if (prop_len < 0)
return prop_len;
err = niu_pci_vpd_get_propname(np, start + 5, namebuf, 64); err = niu_pci_vpd_get_propname(np, start + 5, namebuf, 64);
if (err < 0) if (err < 0)
return err; return err;
...@@ -8165,8 +8167,12 @@ static int niu_pci_vpd_scan_props(struct niu *np, u32 start, u32 end) ...@@ -8165,8 +8167,12 @@ static int niu_pci_vpd_scan_props(struct niu *np, u32 start, u32 end)
netif_printk(np, probe, KERN_DEBUG, np->dev, netif_printk(np, probe, KERN_DEBUG, np->dev,
"VPD_SCAN: Reading in property [%s] len[%d]\n", "VPD_SCAN: Reading in property [%s] len[%d]\n",
namebuf, prop_len); namebuf, prop_len);
for (i = 0; i < prop_len; i++) for (i = 0; i < prop_len; i++) {
*prop_buf++ = niu_pci_eeprom_read(np, off + i); err = niu_pci_eeprom_read(np, off + i);
if (err >= 0)
*prop_buf = err;
++prop_buf;
}
} }
start += len; start += len;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment