1
0
Fork 0

net/fm: call fm_port_to_index() with proper checks

Some of the fm_port_to_index() callers did not check for -1 return value and
used -1 as an array index.

Signed-off-by: Marian Rotariu <marian.rotariu@freescale.com>
Reviewed-by: York Sun <yorksun@freescale.com>
utp
Rotariu Marian-Cristian 2014-05-19 10:59:52 +03:00 committed by York Sun
parent 605714f669
commit 1155d8d853
2 changed files with 8 additions and 1 deletions

View File

@ -143,6 +143,7 @@ struct fm_eth {
#define MAX_RXBUF_LOG2 11
#define MAX_RXBUF_LEN (1 << MAX_RXBUF_LOG2)
#define PORT_IS_ENABLED(port) fm_info[fm_port_to_index(port)].enabled
#define PORT_IS_ENABLED(port) (fm_port_to_index(port) == -1 ? \
0 : fm_info[fm_port_to_index(port)].enabled)
#endif /* __FM_H__ */

View File

@ -147,6 +147,9 @@ void fm_disable_port(enum fm_port port)
{
int i = fm_port_to_index(port);
if (i == -1)
return;
fm_info[i].enabled = 0;
fman_disable_port(port);
}
@ -155,6 +158,9 @@ void fm_enable_port(enum fm_port port)
{
int i = fm_port_to_index(port);
if (i == -1)
return;
fm_info[i].enabled = 1;
fman_enable_port(port);
}