Subject: Re: [PATCH net-next 0/2] net: Use helper function IS_ERR_OR_NULL()

From: Leon Romanovsky <[email-masked]>
Date: Thu, 17 Aug 2023 11:02:57 +0300

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 <[email-masked]>

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         }