nfp: prevent theoretical buffer overrun in nfp_eth_read_ports
authorSimon Horman <simon.horman@netronome.com>
Wed, 8 Mar 2017 16:57:08 +0000 (08:57 -0800)
committerDavid S. Miller <davem@davemloft.net>
Fri, 10 Mar 2017 00:39:58 +0000 (16:39 -0800)
commit5692dbb56e6012c0755614ee64fe4c221f357e7a
tree15c1fd7c703b0994ccff2ac1c04118f47bd33e66
parentb9dcf88a47ebab2743a0c627a95126c4cb3e9883
nfp: prevent theoretical buffer overrun in nfp_eth_read_ports

Prevent theoretical buffer overrun by returning an error if
the number of entries returned by the firmware does not match those
present.

Also use a common handling error path.

Found by inspection.

Signed-off-by: Simon Horman <simon.horman@netronome.com>
Tested-by: Jakub Kicinski <jakub.kicinski@netronome.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/netronome/nfp/nfpcore/nfp_nsp_eth.c