Netdev Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Petr Machata <petrm@nvidia.com>
To: Ido Schimmel <idosch@idosch.org>
Cc: Bjorn Helgaas <helgaas@kernel.org>, <netdev@vger.kernel.org>,
	<davem@davemloft.net>, <kuba@kernel.org>, <jiri@mellanox.com>,
	<mlxsw@mellanox.com>, Ido Schimmel <idosch@mellanox.com>
Subject: Re: [PATCH net-next 03/11] mlxsw: spectrum_policer: Add policer core
Date: Tue, 18 Aug 2020 11:37:45 +0200	[thread overview]
Message-ID: <87wo1we1li.fsf@nvidia.com> (raw)
In-Reply-To: <20200818064151.GA214959@shredder>


Ido Schimmel <idosch@idosch.org> writes:

> On Mon, Aug 17, 2020 at 10:38:24AM -0500, Bjorn Helgaas wrote:
>> You've likely seen this already, but Coverity found this problem:
>> 
>>   *** CID 1466147:  Control flow issues  (DEADCODE)
>>   /drivers/net/ethernet/mellanox/mlxsw/spectrum_policer.c: 380 in mlxsw_sp_policers_init()
>>   374     	}
>>   375     
>>   376     	return 0;
>>   377     
>>   378     err_family_register:
>>   379     	for (i--; i >= 0; i--) {
>>   >>>     CID 1466147:  Control flow issues  (DEADCODE)
>>   >>>     Execution cannot reach this statement: "struct mlxsw_sp_policer_fam...".
>>   380     		struct mlxsw_sp_policer_family *family;
>>   381     
>>   382     		family = mlxsw_sp->policer_core->family_arr[i];
>>   383     		mlxsw_sp_policer_family_unregister(mlxsw_sp, family);
>>   384     	}
>>   385     err_init:
>> 
>> I think the problem is that MLXSW_SP_POLICER_TYPE_MAX is 0 because
>> 
>> > +enum mlxsw_sp_policer_type {
>> > +	MLXSW_SP_POLICER_TYPE_SINGLE_RATE,
>> > +
>> > +	__MLXSW_SP_POLICER_TYPE_MAX,
>> > +	MLXSW_SP_POLICER_TYPE_MAX = __MLXSW_SP_POLICER_TYPE_MAX - 1,
>> > +};
>> 
>> so we can only execute the family_register loop once, with i == 0,
>> and if we get to err_family_register via the error exit:
>> 
>> > +	for (i = 0; i < MLXSW_SP_POLICER_TYPE_MAX + 1; i++) {
>> > +		err = mlxsw_sp_policer_family_register(mlxsw_sp, mlxsw_sp_policer_family_arr[i]);
>> > +		if (err)
>> > +			goto err_family_register;
>> 
>> i will be 0, so i-- sets i to -1, so we don't enter the
>> family_unregister loop body since -1 is not >= 0.
>
> Thanks for the report, but isn't the code doing the right thing here? I
> mean, it's dead code now, but as soon as we add another family it will
> be executed. It seems error prone to remove it only to please Coverity
> and then add it back when it's actually needed.

Agreed.

  reply	other threads:[~2020-08-18  9:41 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-15  8:27 [PATCH net-next 00/11] mlxsw: Offload tc police action Ido Schimmel
2020-07-15  8:27 ` [PATCH net-next 01/11] mlxsw: reg: Add policer bandwidth limits Ido Schimmel
2020-07-15  8:27 ` [PATCH net-next 02/11] mlxsw: resources: Add resource identifier for global policers Ido Schimmel
2020-07-15  8:27 ` [PATCH net-next 03/11] mlxsw: spectrum_policer: Add policer core Ido Schimmel
2020-08-17 15:38   ` Bjorn Helgaas
2020-08-18  6:41     ` Ido Schimmel
2020-08-18  9:37       ` Petr Machata [this message]
2020-08-18 12:10         ` Bjorn Helgaas
2020-07-15  8:27 ` [PATCH net-next 04/11] mlxsw: spectrum_policer: Add devlink resource support Ido Schimmel
2020-07-15  8:27 ` [PATCH net-next 05/11] mlxsw: core_acl_flex_actions: Work around hardware limitation Ido Schimmel
2020-07-15  8:27 ` [PATCH net-next 06/11] mlxsw: core_acl_flex_actions: Add police action Ido Schimmel
2020-07-15  8:27 ` [PATCH net-next 07/11] mlxsw: spectrum_acl: Offload FLOW_ACTION_POLICE Ido Schimmel
2020-07-15  8:27 ` [PATCH net-next 08/11] selftests: forwarding: Add tc-police tests Ido Schimmel
2020-07-15  8:27 ` [PATCH net-next 09/11] selftests: mlxsw: tc_restrictions: Test tc-police restrictions Ido Schimmel
2020-07-15  8:27 ` [PATCH net-next 10/11] selftests: mlxsw: Add scale test for tc-police Ido Schimmel
2020-07-15  8:27 ` [PATCH net-next 11/11] selftests: mlxsw: Test policers' occupancy Ido Schimmel
2020-07-16  1:13 ` [PATCH net-next 00/11] mlxsw: Offload tc police action Jakub Kicinski

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87wo1we1li.fsf@nvidia.com \
    --to=petrm@nvidia.com \
    --cc=davem@davemloft.net \
    --cc=helgaas@kernel.org \
    --cc=idosch@idosch.org \
    --cc=idosch@mellanox.com \
    --cc=jiri@mellanox.com \
    --cc=kuba@kernel.org \
    --cc=mlxsw@mellanox.com \
    --cc=netdev@vger.kernel.org \
    --subject='Re: [PATCH net-next 03/11] mlxsw: spectrum_policer: Add policer core' \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).