]> git.baikalelectronics.ru Git - kernel.git/commit
i40e: i40e_main: fix a missing check on list iterator
authorXiaomeng Tong <xiam0nd.tong@gmail.com>
Tue, 10 May 2022 20:48:46 +0000 (13:48 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 18 May 2022 08:26:56 +0000 (10:26 +0200)
commitbfc5253efac46c7f1ea2cfd3632c787673465b46
tree407364ad1c2ce00babd51729477649066379fff4
parentec44ed309681f0df086817fb018688d201926828
i40e: i40e_main: fix a missing check on list iterator

commit 6bba113fa334a2f1a25bc5644c241a7ce8074b57 upstream.

The bug is here:
ret = i40e_add_macvlan_filter(hw, ch->seid, vdev->dev_addr, &aq_err);

The list iterator 'ch' will point to a bogus position containing
HEAD if the list is empty or no element is found. This case must
be checked before any use of the iterator, otherwise it will
lead to a invalid memory access.

To fix this bug, use a new variable 'iter' as the list iterator,
while use the origin variable 'ch' as a dedicated pointer to
point to the found element.

Cc: stable@vger.kernel.org
Fixes: 24f24390696a0 ("i40e: Add macvlan support on i40e")
Signed-off-by: Xiaomeng Tong <xiam0nd.tong@gmail.com>
Tested-by: Gurucharan <gurucharanx.g@intel.com> (A Contingent worker at Intel)
Signed-off-by: Tony Nguyen <anthony.l.nguyen@intel.com>
Link: https://lore.kernel.org/r/20220510204846.2166999-1-anthony.l.nguyen@intel.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/net/ethernet/intel/i40e/i40e_main.c