All of lore.kernel.org
 help / color / mirror / Atom feed
From: Leon Romanovsky <leon@kernel.org>
To: Ruan Jinjie <ruanjinjie@huawei.com>
Cc: davem@davemloft.net, edumazet@google.com, kuba@kernel.org,
	pabeni@redhat.com, lars.povlsen@microchip.com,
	Steen.Hegelund@microchip.com, daniel.machon@microchip.com,
	alexandre.torgue@foss.st.com, joabreu@synopsys.com,
	mcoquelin.stm32@gmail.com, horatiu.vultur@microchip.com,
	simon.horman@corigine.com, netdev@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org,
	linux-stm32@st-md-mailman.stormreply.com
Subject: Re: [PATCH net-next 0/2] net: Use helper function IS_ERR_OR_NULL()
Date: Thu, 17 Aug 2023 11:02:57 +0300	[thread overview]
Message-ID: <20230817080257.GD22185@unreal> (raw)
In-Reply-To: <20230817071941.346590-1-ruanjinjie@huawei.com>

On Thu, Aug 17, 2023 at 03:19:39PM +0800, Ruan Jinjie wrote:
> Use IS_ERR_OR_NULL() instead of open-coding it
> to simplify the code.
> 
> Ruan Jinjie (2):
>   net: microchip: sparx5: Use helper function IS_ERR_OR_NULL()
>   net: stmmac: Use helper function IS_ERR_OR_NULL()
> 
>  drivers/net/ethernet/microchip/sparx5/sparx5_tc_flower.c | 2 +-
>  drivers/net/ethernet/stmicro/stmmac/stmmac_main.c        | 2 +-
>  2 files changed, 2 insertions(+), 2 deletions(-)
> 

Thanks,
Reviewed-by: Leon Romanovsky <leonro@nvidia.com>

As a side note, grep of vcap_get_rule() shows that many callers don't
properly check return value and expect it to be or valid or NULL.

For example this code is not correct:
drivers/net/ethernet/microchip/lan966x/lan966x_ptp.c
    61         vrule = vcap_get_rule(lan966x->vcap_ctrl, rule_id);
    62         if (vrule) {
    63                 u32 value, mask;
    64
    65                 /* Just modify the ingress port mask and exit */
    66                 vcap_rule_get_key_u32(vrule, VCAP_KF_IF_IGR_PORT_MASK,
    67                                       &value, &mask);
    68                 mask &= ~BIT(port->chip_port);
    69                 vcap_rule_mod_key_u32(vrule, VCAP_KF_IF_IGR_PORT_MASK,
    70                                       value, mask);
    71
    72                 err = vcap_mod_rule(vrule);
    73                 goto free_rule;
    74         }


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

WARNING: multiple messages have this Message-ID (diff)
From: Leon Romanovsky <leon@kernel.org>
To: Ruan Jinjie <ruanjinjie@huawei.com>
Cc: davem@davemloft.net, edumazet@google.com, kuba@kernel.org,
	pabeni@redhat.com, lars.povlsen@microchip.com,
	Steen.Hegelund@microchip.com, daniel.machon@microchip.com,
	alexandre.torgue@foss.st.com, joabreu@synopsys.com,
	mcoquelin.stm32@gmail.com, horatiu.vultur@microchip.com,
	simon.horman@corigine.com, netdev@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org,
	linux-stm32@st-md-mailman.stormreply.com
Subject: Re: [PATCH net-next 0/2] net: Use helper function IS_ERR_OR_NULL()
Date: Thu, 17 Aug 2023 11:02:57 +0300	[thread overview]
Message-ID: <20230817080257.GD22185@unreal> (raw)
In-Reply-To: <20230817071941.346590-1-ruanjinjie@huawei.com>

On Thu, Aug 17, 2023 at 03:19:39PM +0800, Ruan Jinjie wrote:
> Use IS_ERR_OR_NULL() instead of open-coding it
> to simplify the code.
> 
> Ruan Jinjie (2):
>   net: microchip: sparx5: Use helper function IS_ERR_OR_NULL()
>   net: stmmac: Use helper function IS_ERR_OR_NULL()
> 
>  drivers/net/ethernet/microchip/sparx5/sparx5_tc_flower.c | 2 +-
>  drivers/net/ethernet/stmicro/stmmac/stmmac_main.c        | 2 +-
>  2 files changed, 2 insertions(+), 2 deletions(-)
> 

Thanks,
Reviewed-by: Leon Romanovsky <leonro@nvidia.com>

As a side note, grep of vcap_get_rule() shows that many callers don't
properly check return value and expect it to be or valid or NULL.

For example this code is not correct:
drivers/net/ethernet/microchip/lan966x/lan966x_ptp.c
    61         vrule = vcap_get_rule(lan966x->vcap_ctrl, rule_id);
    62         if (vrule) {
    63                 u32 value, mask;
    64
    65                 /* Just modify the ingress port mask and exit */
    66                 vcap_rule_get_key_u32(vrule, VCAP_KF_IF_IGR_PORT_MASK,
    67                                       &value, &mask);
    68                 mask &= ~BIT(port->chip_port);
    69                 vcap_rule_mod_key_u32(vrule, VCAP_KF_IF_IGR_PORT_MASK,
    70                                       value, mask);
    71
    72                 err = vcap_mod_rule(vrule);
    73                 goto free_rule;
    74         }


  parent reply	other threads:[~2023-08-17  8:03 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-08-17  7:19 [PATCH net-next 0/2] net: Use helper function IS_ERR_OR_NULL() Ruan Jinjie
2023-08-17  7:19 ` Ruan Jinjie
2023-08-17  7:19 ` [PATCH net-next 1/2] net: microchip: sparx5: " Ruan Jinjie
2023-08-17  7:19   ` Ruan Jinjie
2023-08-17  7:19 ` [PATCH net-next 2/2] net: stmmac: " Ruan Jinjie
2023-08-17  7:19   ` Ruan Jinjie
2023-08-17 10:07   ` Russell King (Oracle)
2023-08-17 10:07     ` Russell King (Oracle)
2023-08-17  8:02 ` Leon Romanovsky [this message]
2023-08-17  8:02   ` [PATCH net-next 0/2] net: " Leon Romanovsky
2023-08-17  9:50   ` Ruan Jinjie
2023-08-17  9:50     ` Ruan Jinjie

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=20230817080257.GD22185@unreal \
    --to=leon@kernel.org \
    --cc=Steen.Hegelund@microchip.com \
    --cc=alexandre.torgue@foss.st.com \
    --cc=daniel.machon@microchip.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=horatiu.vultur@microchip.com \
    --cc=joabreu@synopsys.com \
    --cc=kuba@kernel.org \
    --cc=lars.povlsen@microchip.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-stm32@st-md-mailman.stormreply.com \
    --cc=mcoquelin.stm32@gmail.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=ruanjinjie@huawei.com \
    --cc=simon.horman@corigine.com \
    /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
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.