diff mbox series

[net] Revert "flow_offload: action should not be NULL when it is referenced"

Message ID 20210819105842.1315705-1-idosch@idosch.org (mailing list archive)
State Accepted
Delegated to: Netdev Maintainers
Headers show
Series [net] Revert "flow_offload: action should not be NULL when it is referenced" | expand

Checks

Context Check Description
netdev/cover_letter success Link
netdev/fixes_present success Link
netdev/patch_count success Link
netdev/tree_selection success Clearly marked for net
netdev/subject_prefix success Link
netdev/cc_maintainers success CCed 4 of 4 maintainers
netdev/source_inline success Was 0 now: 0
netdev/verify_signedoff success Link
netdev/module_param success Was 0 now: 0
netdev/build_32bit success Errors and warnings before: 3606 this patch: 3606
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/verify_fixes success Link
netdev/checkpatch warning WARNING: line length of 105 exceeds 80 columns
netdev/build_allmodconfig_warn success Errors and warnings before: 3762 this patch: 3762
netdev/header_inline success Link

Commit Message

Ido Schimmel Aug. 19, 2021, 10:58 a.m. UTC
From: Ido Schimmel <idosch@nvidia.com>

This reverts commit 9ea3e52c5bc8bb4a084938dc1e3160643438927a.

Cited commit added a check to make sure 'action' is not NULL, but
'action' is already dereferenced before the check, when calling
flow_offload_has_one_action().

Therefore, the check does not make any sense and results in a smatch
warning:

include/net/flow_offload.h:322 flow_action_mixed_hw_stats_check() warn:
variable dereferenced before check 'action' (see line 319)

Fix by reverting this commit.

Cc: gushengxian <gushengxian@yulong.com>
Fixes: 9ea3e52c5bc8 ("flow_offload: action should not be NULL when it is referenced")
Signed-off-by: Ido Schimmel <idosch@nvidia.com>
---
 include/net/flow_offload.h | 12 +++++-------
 1 file changed, 5 insertions(+), 7 deletions(-)

Comments

Jamal Hadi Salim Aug. 19, 2021, 11:51 a.m. UTC | #1
On 2021-08-19 6:58 a.m., Ido Schimmel wrote:
> From: Ido Schimmel <idosch@nvidia.com>
> 
> This reverts commit 9ea3e52c5bc8bb4a084938dc1e3160643438927a.
> 
> Cited commit added a check to make sure 'action' is not NULL, but
> 'action' is already dereferenced before the check, when calling
> flow_offload_has_one_action().
> 
> Therefore, the check does not make any sense and results in a smatch
> warning:
> 
> include/net/flow_offload.h:322 flow_action_mixed_hw_stats_check() warn:
> variable dereferenced before check 'action' (see line 319)
> 
> Fix by reverting this commit.
> 
> Cc: gushengxian <gushengxian@yulong.com>
> Fixes: 9ea3e52c5bc8 ("flow_offload: action should not be NULL when it is referenced")
> Signed-off-by: Ido Schimmel <idosch@nvidia.com>

Acked-by: Jamal Hadi Salim <jhs@mojatatu.com>

cheers,
jamal
Jakub Kicinski Aug. 19, 2021, 6:15 p.m. UTC | #2
On Thu, 19 Aug 2021 07:51:15 -0400 Jamal Hadi Salim wrote:
> On 2021-08-19 6:58 a.m., Ido Schimmel wrote:
> > From: Ido Schimmel <idosch@nvidia.com>
> > 
> > This reverts commit 9ea3e52c5bc8bb4a084938dc1e3160643438927a.
> > 
> > Cited commit added a check to make sure 'action' is not NULL, but
> > 'action' is already dereferenced before the check, when calling
> > flow_offload_has_one_action().
> > 
> > Therefore, the check does not make any sense and results in a smatch
> > warning:
> > 
> > include/net/flow_offload.h:322 flow_action_mixed_hw_stats_check() warn:
> > variable dereferenced before check 'action' (see line 319)
> > 
> > Fix by reverting this commit.
> > 
> > Cc: gushengxian <gushengxian@yulong.com>
> > Fixes: 9ea3e52c5bc8 ("flow_offload: action should not be NULL when it is referenced")
> > Signed-off-by: Ido Schimmel <idosch@nvidia.com>  
> 
> Acked-by: Jamal Hadi Salim <jhs@mojatatu.com>

Applied, thanks!
diff mbox series

Patch

diff --git a/include/net/flow_offload.h b/include/net/flow_offload.h
index f3c2841566a0..1b9d75aedb22 100644
--- a/include/net/flow_offload.h
+++ b/include/net/flow_offload.h
@@ -319,14 +319,12 @@  flow_action_mixed_hw_stats_check(const struct flow_action *action,
 	if (flow_offload_has_one_action(action))
 		return true;
 
-	if (action) {
-		flow_action_for_each(i, action_entry, action) {
-			if (i && action_entry->hw_stats != last_hw_stats) {
-				NL_SET_ERR_MSG_MOD(extack, "Mixing HW stats types for actions is not supported");
-				return false;
-			}
-			last_hw_stats = action_entry->hw_stats;
+	flow_action_for_each(i, action_entry, action) {
+		if (i && action_entry->hw_stats != last_hw_stats) {
+			NL_SET_ERR_MSG_MOD(extack, "Mixing HW stats types for actions is not supported");
+			return false;
 		}
+		last_hw_stats = action_entry->hw_stats;
 	}
 	return true;
 }