Skip to content

Commit e4c7981

Browse files
HBh25Ydavem330
authored andcommitted
net: ethernet: mtk_eth_soc: fix possible NULL pointer dereference in mtk_hwlro_get_fdir_all()
rule_locs is allocated in ethtool_get_rxnfc and the size is determined by rule_cnt from user space. So rule_cnt needs to be check before using rule_locs to avoid NULL pointer dereference. Fixes: 7aab747 ("net: ethernet: mediatek: add ethtool functions to configure RX flows of HW LRO") Signed-off-by: Hangyu Hua <[email protected]> Reviewed-by: Simon Horman <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 51fe0a4 commit e4c7981

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

drivers/net/ethernet/mediatek/mtk_eth_soc.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2994,6 +2994,9 @@ static int mtk_hwlro_get_fdir_all(struct net_device *dev,
29942994
int i;
29952995

29962996
for (i = 0; i < MTK_MAX_LRO_IP_CNT; i++) {
2997+
if (cnt == cmd->rule_cnt)
2998+
return -EMSGSIZE;
2999+
29973000
if (mac->hwlro_ip[i]) {
29983001
rule_locs[cnt] = i;
29993002
cnt++;

0 commit comments

Comments
 (0)