]> git.baikalelectronics.ru Git - kernel.git/commit
ethtool: fix error handling in ethtool_phys_id
authorEdward Cree <ecree@solarflare.com>
Tue, 1 Sep 2020 17:52:32 +0000 (18:52 +0100)
committerDavid S. Miller <davem@davemloft.net>
Thu, 3 Sep 2020 21:59:51 +0000 (14:59 -0700)
commited9fbf7ec9e1bb11d7df44bcb9622b93752b5ff1
tree3b2e454129b95babe7b6a83fee1c1edbd40bef50
parent5b9ca30c2cd31f9c484efb910e2a4b0908983fb6
ethtool: fix error handling in ethtool_phys_id

If ops->set_phys_id() returned an error, previously we would only break
 out of the inner loop, which neither stopped the outer loop nor returned
 the error to the user (since 'rc' would be overwritten on the next pass
 through the loop).
Thus, rewrite it to use a single loop, so that the break does the right
 thing.  Use u64 for 'count' and 'i' to prevent overflow in case of
 (unreasonably) large values of id.data and n.

Signed-off-by: Edward Cree <ecree@solarflare.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/ethtool/ioctl.c