2021-08-18 12:00:30

by Ido Schimmel

[permalink] [raw]
Subject: Re: [PATCH] flow_offload: action should not be NULL when it is referenced

On Sat, Jun 26, 2021 at 04:56:06AM -0700, [email protected] wrote:
> From: gushengxian <[email protected]>
>
> "action" should not be NULL when it is referenced.
>
> Signed-off-by: gushengxian <[email protected]>
> Signed-off-by: gushengxian <[email protected]>
> ---
> include/net/flow_offload.h | 12 +++++++-----
> 1 file changed, 7 insertions(+), 5 deletions(-)
>
> diff --git a/include/net/flow_offload.h b/include/net/flow_offload.h
> index dc5c1e69cd9f..69c9eabf8325 100644
> --- a/include/net/flow_offload.h
> +++ b/include/net/flow_offload.h
> @@ -319,12 +319,14 @@ flow_action_mixed_hw_stats_check(const struct flow_action *action,
> if (flow_offload_has_one_action(action))
> return true;
>
> - 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;
> + if (action) {

This patch generates a smatch warning:

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

Why the patch is needed? 'action' is already dereferenced in
flow_offload_has_one_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;
> }
> - last_hw_stats = action_entry->hw_stats;
> }
> return true;
> }
> --
> 2.25.1
>
>


2021-08-18 12:39:04

by Jamal Hadi Salim

[permalink] [raw]
Subject: Re: [PATCH] flow_offload: action should not be NULL when it is referenced

On 2021-08-18 7:58 a.m., Ido Schimmel wrote:
> On Sat, Jun 26, 2021 at 04:56:06AM -0700, [email protected] wrote:
>> From: gushengxian <[email protected]>
>>
>> "action" should not be NULL when it is referenced.
>>
>> Signed-off-by: gushengxian <[email protected]>
>> Signed-off-by: gushengxian <[email protected]>
>> ---
>> include/net/flow_offload.h | 12 +++++++-----
>> 1 file changed, 7 insertions(+), 5 deletions(-)
>>
>> diff --git a/include/net/flow_offload.h b/include/net/flow_offload.h
>> index dc5c1e69cd9f..69c9eabf8325 100644
>> --- a/include/net/flow_offload.h
>> +++ b/include/net/flow_offload.h
>> @@ -319,12 +319,14 @@ flow_action_mixed_hw_stats_check(const struct flow_action *action,
>> if (flow_offload_has_one_action(action))
>> return true;
>>
>> - 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;
>> + if (action) {
>
> This patch generates a smatch warning:
>
> include/net/flow_offload.h:322 flow_action_mixed_hw_stats_check() warn: variable dereferenced before check 'action' (see line 319)
>
> Why the patch is needed? 'action' is already dereferenced in
> flow_offload_has_one_action()
>

Yep, doesnt make sense at all.

cheers,
jamal

2021-08-18 13:43:45

by Ido Schimmel

[permalink] [raw]
Subject: Re: [PATCH] flow_offload: action should not be NULL when it is referenced

On Wed, Aug 18, 2021 at 08:36:55AM -0400, Jamal Hadi Salim wrote:
> On 2021-08-18 7:58 a.m., Ido Schimmel wrote:
> > On Sat, Jun 26, 2021 at 04:56:06AM -0700, [email protected] wrote:
> > > From: gushengxian <[email protected]>
> > >
> > > "action" should not be NULL when it is referenced.
> > >
> > > Signed-off-by: gushengxian <[email protected]>
> > > Signed-off-by: gushengxian <[email protected]>
> > > ---
> > > include/net/flow_offload.h | 12 +++++++-----
> > > 1 file changed, 7 insertions(+), 5 deletions(-)
> > >
> > > diff --git a/include/net/flow_offload.h b/include/net/flow_offload.h
> > > index dc5c1e69cd9f..69c9eabf8325 100644
> > > --- a/include/net/flow_offload.h
> > > +++ b/include/net/flow_offload.h
> > > @@ -319,12 +319,14 @@ flow_action_mixed_hw_stats_check(const struct flow_action *action,
> > > if (flow_offload_has_one_action(action))
> > > return true;
> > > - 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;
> > > + if (action) {
> >
> > This patch generates a smatch warning:
> >
> > include/net/flow_offload.h:322 flow_action_mixed_hw_stats_check() warn: variable dereferenced before check 'action' (see line 319)
> >
> > Why the patch is needed? 'action' is already dereferenced in
> > flow_offload_has_one_action()
> >
>
> Yep, doesnt make sense at all.

Will send a revert