RE: [PATCH] ice: ice_sched: fix an incorrect NULL check on list iterator

From: Raj, Victor
Date: Mon May 02 2022 - 21:08:53 EST


If the control comes down to the loop then surely the VSI is already part of an aggregator (old). The aggregator vsi list should have that VSI information. My understanding is that if control comes here then you always find a valid entry and matching handle here. If that doesn't happen then we need to debug. The fix is kind of masking this problem.

-Victor



-----Original Message-----
From: G, GurucharanX <gurucharanx.g@xxxxxxxxx>
Sent: Monday, May 2, 2022 1:18 AM
To: Keller, Jacob E <jacob.e.keller@xxxxxxxxx>; Xiaomeng Tong <xiam0nd.tong@xxxxxxxxx>; Brandeburg, Jesse <jesse.brandeburg@xxxxxxxxx>
Cc: netdev@xxxxxxxxxxxxxxx; Raj, Victor <victor.raj@xxxxxxxxx>; stable@xxxxxxxxxxxxxxx; linux-kernel@xxxxxxxxxxxxxxx; intel-wired-lan@xxxxxxxxxxxxxxxx; kuba@xxxxxxxxxx; pabeni@xxxxxxxxxx; davem@xxxxxxxxxxxxx
Subject: RE: [PATCH] ice: ice_sched: fix an incorrect NULL check on list iterator



-----Original Message-----
> From: Xiaomeng Tong <xiam0nd.tong@xxxxxxxxx>
> Sent: Saturday, March 26, 2022 11:44 PM
> To: Brandeburg, Jesse <jesse.brandeburg@xxxxxxxxx>
> Cc: Nguyen, Anthony L <anthony.l.nguyen@xxxxxxxxx>;
> davem@xxxxxxxxxxxxx; kuba@xxxxxxxxxx; pabeni@xxxxxxxxxx; Raj, Victor
> <victor.raj@xxxxxxxxx>; intel- wired-lan@xxxxxxxxxxxxxxxx;
> netdev@xxxxxxxxxxxxxxx; linux- kernel@xxxxxxxxxxxxxxx; Xiaomeng Tong
> <xiam0nd.tong@xxxxxxxxx>; stable@xxxxxxxxxxxxxxx
> Subject: [PATCH] ice: ice_sched: fix an incorrect NULL check on list
> iterator
>
> The bugs are here:
> if (old_agg_vsi_info)
> if (old_agg_vsi_info && !old_agg_vsi_info->tc_bitmap[0]) {
>
> The list iterator value 'old_agg_vsi_info' will *always* be set and
> non-NULL by list_for_each_entry_safe(), so it is incorrect to assume
> that the iterator value will be NULL if the list is empty or no
> element found (in this case, the check 'if (old_agg_vsi_info)' will
> always be true unexpectly).
>
> To fix the bug, use a new variable 'iter' as the list iterator, while
> use the original variable 'old_agg_vsi_info' as a dedicated pointer to
> point to the found element.
>

Yep. This looks correct to me.

> Reviewed-by: Jacob Keller <jacob.e.keller@xxxxxxxxx>
>
> Thanks,
> Jake

> Cc: stable@xxxxxxxxxxxxxxx
> Fixes: 37c592062b16d ("ice: remove the VSI info from previous agg")
> Signed-off-by: Xiaomeng Tong <xiam0nd.tong@xxxxxxxxx>
> ---
> drivers/net/ethernet/intel/ice/ice_sched.c | 7 +++++--
> 1 file changed, 5 insertions(+), 2 deletions(-)
>

Tested-by: Gurucharan <gurucharanx.g@xxxxxxxxx> (A Contingent worker at Intel)