Skip to content

Commit

Permalink
net: ethernet: mtk_eth_soc: fix possible NULL pointer dereference in …
Browse files Browse the repository at this point in the history
…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 <hbh25y@gmail.com>
Reviewed-by: Simon Horman <horms@kernel.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Hangyu Hua authored and David S. Miller committed Sep 11, 2023
1 parent 51fe0a4 commit e4c7981
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions drivers/net/ethernet/mediatek/mtk_eth_soc.c
Original file line number Diff line number Diff line change
Expand Up @@ -2994,6 +2994,9 @@ static int mtk_hwlro_get_fdir_all(struct net_device *dev,
int i;

for (i = 0; i < MTK_MAX_LRO_IP_CNT; i++) {
if (cnt == cmd->rule_cnt)
return -EMSGSIZE;

if (mac->hwlro_ip[i]) {
rule_locs[cnt] = i;
cnt++;
Expand Down

0 comments on commit e4c7981

Please sign in to comment.