net: usb: pegasus: fix improper read if get_registers() fail
Subsystems (4)
PATCH 1/1 net: usb: pegasus: fix improper read if get_registers() fail
get_registers() may fail with -ENOMEM and in this case we can read a garbage from the status variable tmp.
--- drivers/net/usb/pegasus.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/usb/pegasus.c +1 -1
@@ -282,7 +282,7 @@ static void mdio_write(struct net_device *dev, int phy_id, int loc, int val)static int read_eprom_word (pegasus_t *pegasus,__u8 index,__u16 *retdata) {int i; -__u8 tmp; +__u8 tmp =0 ;__le16 retdatai;int ret;
Signature · 1 line
2.12.3
David Miller
maintainerFrom: Denis Kirjanov <[email protected]>
Date: Tue, 30 Jul 2019 15:13:57 +0200
Quoted 5 lines
get_registers()may fail with-ENOMEMand in this case we can read a garbage from the status variable tmp.Reported-by [email protected]Signed-off-by Denis Kirjanov <[email protected]>
Why did you post this patch twice? What is different between the two versions?
Quoted 12 lines · David Miller
From: Denis Kirjanov <[email protected]>
Date: Tue, 30 Jul 2019 15:13:57 +0200Quoted 5 lines
get_registers()may fail with-ENOMEMand in this case we can read a garbage from the status variable tmp.Reported-by [email protected]Signed-off-by Denis Kirjanov <[email protected]>Why did you post this patch twice? What is different between the two versions?
Looks like it was the issue with git send-email. Sorry about that. Do you want me to figure out the reason and resend?
A message that is not in the archive (sent off-list or not yet received): CAHj3AVm2EZB7n9UBxiBmA+6XN+EgAC_FRoHjh6kO3WMT8KVd6g@mail.gmail.com
David Miller
maintainerFrom: Denis Kirjanov <[email protected]>
Date: Tue, 30 Jul 2019 21:19:46 +0300
Quoted 11 lines · David Miller
Quoted 10 lines
From: Denis Kirjanov <[email protected]>
Date: Tue, 30 Jul 2019 15:13:57 +0200Quoted 5 lines
get_registers()may fail with-ENOMEMand in this case we can read a garbage from the status variable tmp.Reported-by [email protected]Signed-off-by Denis Kirjanov <[email protected]>
Quoted 6 lines
Quoted 2 lines
Why did you post this patch twice? What is different between the two versions?
Looks like it’s the issue with git send-email :/ Do you want me to figure out the reason and resend?
No need, I was just curious.
Petko Manolov
maintainerQuoted 14 lines · Denis Kirjanov
get_registers()may fail with-ENOMEMand in this case we can read a garbage from the status variable tmp.Reported-by [email protected]Signed-off-by Denis Kirjanov <[email protected]>--- drivers/net/usb/pegasus.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/net/usb/pegasus.c +0
-0
drivers/net/usb/pegasus.c static void mdio_write(struct net_device *dev, int phy_id, int loc, int val) · line 287
Quoted 7 lines
drivers/net/usb/pegasus.c +1
-1@@ -282,7 +282,7 @@ static void mdio_write(struct net_device *dev, int phy_id, int loc, int val)static int read_eprom_word (pegasus_t *pegasus,__u8 index,__u16 *retdata) {int i; -__u8 tmp; +__u8 tmp =0 ;__le16 retdatai;int ret;
Unfortunately this patch does not fix anything. Even if get_registers() fail with -ENOMEM the "for" loop will cover for it and will exit only if the operation was successful or the device got disconnected. Please read the code carefully.
So while the patch is harmless it isn't solving a problem.
cheers,
Petko
Petko Manolov
maintainerQuoted 28 lines · Petko Manolov
Quoted 14 lines · Denis Kirjanov
get_registers()may fail with-ENOMEMand in this case we can read a garbage from the status variable tmp.Reported-by [email protected]Signed-off-by Denis Kirjanov <[email protected]>--- drivers/net/usb/pegasus.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/net/usb/pegasus.c +0
-0drivers/net/usb/pegasus.c static void mdio_write(struct net_device *dev, int phy_id, int loc, int val) · line 287
Quoted 7 lines
drivers/net/usb/pegasus.c +1
-1@@ -282,7 +282,7 @@ static void mdio_write(struct net_device *dev, int phy_id, int loc, int val)static int read_eprom_word (pegasus_t *pegasus,__u8 index,__u16 *retdata) {int i; -__u8 tmp; +__u8 tmp =0 ;__le16 retdatai;int ret;Unfortunately this patch does not fix anything. Even if
get_registers()fail with-ENOMEMthe "for" loop will cover for it and will exit only if the operation was successful or the device got disconnected. Please read the code carefully.
Quoted 1 line
So while the patch is harmless it isn't solving a problem.
Actually i am wrong - if "tmp" contains a random value it may accidentally have the EPROM_DONE bit set.
Dave, please apply the patch.
thanks,
Petko
From: Denis Kirjanov <[email protected]>
Date: Tue, 30 Jul 2019 15:13:57 +0200
Quoted 5 lines
get_registers()may fail with-ENOMEMand in this case we can read a garbage from the status variable tmp.Reported-by [email protected]Signed-off-by Denis Kirjanov <[email protected]>
Applied, thank you.