* [PATCH] ethernet: (niu) fix missing checks of niu_pci_eeprom_read
@ 2018-12-25 7:56 Kangjie Lu
2018-12-26 18:08 ` Shannon Nelson
2018-12-28 0:19 ` David Miller
0 siblings, 2 replies; 3+ messages in thread
From: Kangjie Lu @ 2018-12-25 7:56 UTC (permalink / raw)
To: kjlu
Cc: pakki001, David S. Miller, Shannon Nelson, Colin Ian King,
Rob Taglang, Joe Perches, netdev, linux-kernel
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>
---
drivers/net/ethernet/sun/niu.c | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
diff --git a/drivers/net/ethernet/sun/niu.c b/drivers/net/ethernet/sun/niu.c
index 9319d84bf49f..d84501441edd 100644
--- a/drivers/net/ethernet/sun/niu.c
+++ b/drivers/net/ethernet/sun/niu.c
@@ -8100,6 +8100,8 @@ static int niu_pci_vpd_scan_props(struct niu *np, u32 start, u32 end)
start += 3;
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);
if (err < 0)
return err;
@@ -8144,8 +8146,12 @@ static int niu_pci_vpd_scan_props(struct niu *np, u32 start, u32 end)
netif_printk(np, probe, KERN_DEBUG, np->dev,
"VPD_SCAN: Reading in property [%s] len[%d]\n",
namebuf, prop_len);
- for (i = 0; i < prop_len; i++)
- *prop_buf++ = niu_pci_eeprom_read(np, off + i);
+ for (i = 0; i < prop_len; i++) {
+ err = niu_pci_eeprom_read(np, off + i);
+ if (err >= 0)
+ *prop_buf = err;
+ ++prop_buf;
+ }
}
start += len;
--
2.17.2 (Apple Git-113)
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] ethernet: (niu) fix missing checks of niu_pci_eeprom_read
2018-12-25 7:56 [PATCH] ethernet: (niu) fix missing checks of niu_pci_eeprom_read Kangjie Lu
@ 2018-12-26 18:08 ` Shannon Nelson
2018-12-28 0:19 ` David Miller
1 sibling, 0 replies; 3+ messages in thread
From: Shannon Nelson @ 2018-12-26 18:08 UTC (permalink / raw)
To: Kangjie Lu
Cc: pakki001, David S. Miller, Shannon Nelson, Colin Ian King,
Rob Taglang, Joe Perches, netdev, linux-kernel
On Mon, Dec 24, 2018 at 11:58 PM Kangjie Lu <kjlu@umn.edu> wrote:
>
> 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>
> ---
> drivers/net/ethernet/sun/niu.c | 10 ++++++++--
> 1 file changed, 8 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/net/ethernet/sun/niu.c b/drivers/net/ethernet/sun/niu.c
> index 9319d84bf49f..d84501441edd 100644
> --- a/drivers/net/ethernet/sun/niu.c
> +++ b/drivers/net/ethernet/sun/niu.c
> @@ -8100,6 +8100,8 @@ static int niu_pci_vpd_scan_props(struct niu *np, u32 start, u32 end)
> start += 3;
>
> 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);
> if (err < 0)
> return err;
> @@ -8144,8 +8146,12 @@ static int niu_pci_vpd_scan_props(struct niu *np, u32 start, u32 end)
> netif_printk(np, probe, KERN_DEBUG, np->dev,
> "VPD_SCAN: Reading in property [%s] len[%d]\n",
> namebuf, prop_len);
> - for (i = 0; i < prop_len; i++)
> - *prop_buf++ = niu_pci_eeprom_read(np, off + i);
> + for (i = 0; i < prop_len; i++) {
> + err = niu_pci_eeprom_read(np, off + i);
> + if (err >= 0)
> + *prop_buf = err;
> + ++prop_buf;
> + }
> }
>
> start += len;
> --
> 2.17.2 (Apple Git-113)
>
Acked-by: Shannon Nelson <shannon.lee.nelson@gmail.com>
--
==============================================
Mr. Shannon Nelson Parents can't afford to be squeamish.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] ethernet: (niu) fix missing checks of niu_pci_eeprom_read
2018-12-25 7:56 [PATCH] ethernet: (niu) fix missing checks of niu_pci_eeprom_read Kangjie Lu
2018-12-26 18:08 ` Shannon Nelson
@ 2018-12-28 0:19 ` David Miller
1 sibling, 0 replies; 3+ messages in thread
From: David Miller @ 2018-12-28 0:19 UTC (permalink / raw)
To: kjlu; +Cc: pakki001, shannon.nelson, colin.king, rob, joe, netdev, linux-kernel
From: Kangjie Lu <kjlu@umn.edu>
Date: Tue, 25 Dec 2018 01:56:14 -0600
> 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>
Applied.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2018-12-28 0:19 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-12-25 7:56 [PATCH] ethernet: (niu) fix missing checks of niu_pci_eeprom_read Kangjie Lu
2018-12-26 18:08 ` Shannon Nelson
2018-12-28 0:19 ` David Miller
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).