diff mbox series

[-next,1/2] net/mlx5e: add missing error code in error path

Message ID 20220913143713.1998778-1-yangyingliang@huawei.com (mailing list archive)
State Superseded
Delegated to: Netdev Maintainers
Headers show
Series [-next,1/2] net/mlx5e: add missing error code in error path | expand

Checks

Context Check Description
netdev/tree_selection success Guessed tree name to be net-next
netdev/fixes_present success Fixes tag not required for -next series
netdev/subject_prefix warning Target tree name not specified in the subject
netdev/cover_letter success Single patches do not need cover letters
netdev/patch_count success Link
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 1 this patch: 1
netdev/cc_maintainers warning 5 maintainers not CCed: edumazet@google.com borisp@nvidia.com pabeni@redhat.com leon@kernel.org kuba@kernel.org
netdev/build_clang success Errors and warnings before: 0 this patch: 0
netdev/module_param success Was 0 now: 0
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success Fixes tag looks correct
netdev/build_allmodconfig_warn success Errors and warnings before: 1 this patch: 1
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 28 lines checked
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

Yang Yingliang Sept. 13, 2022, 2:37 p.m. UTC
Add missing error code when mlx5e_macsec_fs_add_rule() or
mlx5e_macsec_fs_init() fails.

Fixes: e467b283ffd5 ("net/mlx5e: Add MACsec TX steering rules")
Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
---
 .../ethernet/mellanox/mlx5/core/en_accel/macsec.c  | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)

Comments

Raed Salem Sept. 14, 2022, 12:35 p.m. UTC | #1
>-----Original Message-----
>From: Yang Yingliang <yangyingliang@huawei.com>
>Sent: Tuesday, 13 September 2022 17:37
>To: netdev@vger.kernel.org; linux-rdma@vger.kernel.org
>Cc: Saeed Mahameed <saeedm@nvidia.com>; Lior Nahmanson
><liorna@nvidia.com>; Raed Salem <raeds@nvidia.com>;
>davem@davemloft.net
>Subject: [PATCH -next 1/2] net/mlx5e: add missing error code in error path
>
>External email: Use caution opening links or attachments
>
>
>Add missing error code when mlx5e_macsec_fs_add_rule() or
>mlx5e_macsec_fs_init() fails.
>
>Fixes: e467b283ffd5 ("net/mlx5e: Add MACsec TX steering rules")
>Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
>---
> .../ethernet/mellanox/mlx5/core/en_accel/macsec.c  | 14 ++++++++++++--
> 1 file changed, 12 insertions(+), 2 deletions(-)
>
>diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_accel/macsec.c
>b/drivers/net/ethernet/mellanox/mlx5/core/en_accel/macsec.c
>index d9d18b039d8c..5fa3e22c8918 100644
>--- a/drivers/net/ethernet/mellanox/mlx5/core/en_accel/macsec.c
>+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_accel/macsec.c
>@@ -194,8 +194,13 @@ static int mlx5e_macsec_init_sa(struct
>macsec_context *ctx,
>                                      MLX5_ACCEL_MACSEC_ACTION_DECRYPT;
>
>        macsec_rule = mlx5e_macsec_fs_add_rule(macsec->macsec_fs, ctx,
>&rule_attrs, &sa->fs_id);
>-       if (IS_ERR_OR_NULL(macsec_rule))
>+       if (IS_ERR_OR_NULL(macsec_rule)) {
>+               if (!macsec_rule)
>+                       err = -ENOMEM;
>+               else
>+                       err = PTR_ERR(macsec_rule);
>                goto destroy_macsec_object;
>+       }
>
>        sa->macsec_rule = macsec_rule;
>
>@@ -1294,8 +1299,13 @@ int mlx5e_macsec_init(struct mlx5e_priv *priv)
>        macsec->mdev = mdev;
>
>        macsec_fs = mlx5e_macsec_fs_init(mdev, priv->netdev);
>-       if (IS_ERR_OR_NULL(macsec_fs))
>+       if (IS_ERR_OR_NULL(macsec_fs)) {
>+               if (!macsec_fs)
>+                       err = -ENOMEM;
>+               else
>+                       err = PTR_ERR(macsec_fs);
>                goto err_out;
>+       }
>
>        macsec->macsec_fs = macsec_fs;
>
>--
Look at mlx5e_macsec_fs_init implementation, it never returns error code, it either returns NULL or a valid Ptr, the use of IS_ERR_OR_NULL is redundant here (same for mlx5e_macsec_fs_add_rule)
>2.25.1
Yang Yingliang Sept. 14, 2022, 1:17 p.m. UTC | #2
On 2022/9/14 20:35, Raed Salem wrote:
>> -----Original Message-----
>> From: Yang Yingliang <yangyingliang@huawei.com>
>> Sent: Tuesday, 13 September 2022 17:37
>> To: netdev@vger.kernel.org; linux-rdma@vger.kernel.org
>> Cc: Saeed Mahameed <saeedm@nvidia.com>; Lior Nahmanson
>> <liorna@nvidia.com>; Raed Salem <raeds@nvidia.com>;
>> davem@davemloft.net
>> Subject: [PATCH -next 1/2] net/mlx5e: add missing error code in error path
>>
>> External email: Use caution opening links or attachments
>>
>>
>> Add missing error code when mlx5e_macsec_fs_add_rule() or
>> mlx5e_macsec_fs_init() fails.
>>
>> Fixes: e467b283ffd5 ("net/mlx5e: Add MACsec TX steering rules")
>> Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
>> ---
>> .../ethernet/mellanox/mlx5/core/en_accel/macsec.c  | 14 ++++++++++++--
>> 1 file changed, 12 insertions(+), 2 deletions(-)
>>
>> diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_accel/macsec.c
>> b/drivers/net/ethernet/mellanox/mlx5/core/en_accel/macsec.c
>> index d9d18b039d8c..5fa3e22c8918 100644
>> --- a/drivers/net/ethernet/mellanox/mlx5/core/en_accel/macsec.c
>> +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_accel/macsec.c
>> @@ -194,8 +194,13 @@ static int mlx5e_macsec_init_sa(struct
>> macsec_context *ctx,
>>                                       MLX5_ACCEL_MACSEC_ACTION_DECRYPT;
>>
>>         macsec_rule = mlx5e_macsec_fs_add_rule(macsec->macsec_fs, ctx,
>> &rule_attrs, &sa->fs_id);
>> -       if (IS_ERR_OR_NULL(macsec_rule))
>> +       if (IS_ERR_OR_NULL(macsec_rule)) {
>> +               if (!macsec_rule)
>> +                       err = -ENOMEM;
>> +               else
>> +                       err = PTR_ERR(macsec_rule);
>>                 goto destroy_macsec_object;
>> +       }
>>
>>         sa->macsec_rule = macsec_rule;
>>
>> @@ -1294,8 +1299,13 @@ int mlx5e_macsec_init(struct mlx5e_priv *priv)
>>         macsec->mdev = mdev;
>>
>>         macsec_fs = mlx5e_macsec_fs_init(mdev, priv->netdev);
>> -       if (IS_ERR_OR_NULL(macsec_fs))
>> +       if (IS_ERR_OR_NULL(macsec_fs)) {
>> +               if (!macsec_fs)
>> +                       err = -ENOMEM;
>> +               else
>> +                       err = PTR_ERR(macsec_fs);
>>                 goto err_out;
>> +       }
>>
>>         macsec->macsec_fs = macsec_fs;
>>
>> --
> Look at mlx5e_macsec_fs_init implementation, it never returns error code, it either returns NULL or a valid Ptr, the use of IS_ERR_OR_NULL is redundant here (same for mlx5e_macsec_fs_add_rule)
Yes, I will replace it with NULL ptr check in v2.

Thanks,
Yang
>> 2.25.1
diff mbox series

Patch

diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_accel/macsec.c b/drivers/net/ethernet/mellanox/mlx5/core/en_accel/macsec.c
index d9d18b039d8c..5fa3e22c8918 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_accel/macsec.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_accel/macsec.c
@@ -194,8 +194,13 @@  static int mlx5e_macsec_init_sa(struct macsec_context *ctx,
 				      MLX5_ACCEL_MACSEC_ACTION_DECRYPT;
 
 	macsec_rule = mlx5e_macsec_fs_add_rule(macsec->macsec_fs, ctx, &rule_attrs, &sa->fs_id);
-	if (IS_ERR_OR_NULL(macsec_rule))
+	if (IS_ERR_OR_NULL(macsec_rule)) {
+		if (!macsec_rule)
+			err = -ENOMEM;
+		else
+			err = PTR_ERR(macsec_rule);
 		goto destroy_macsec_object;
+	}
 
 	sa->macsec_rule = macsec_rule;
 
@@ -1294,8 +1299,13 @@  int mlx5e_macsec_init(struct mlx5e_priv *priv)
 	macsec->mdev = mdev;
 
 	macsec_fs = mlx5e_macsec_fs_init(mdev, priv->netdev);
-	if (IS_ERR_OR_NULL(macsec_fs))
+	if (IS_ERR_OR_NULL(macsec_fs)) {
+		if (!macsec_fs)
+			err = -ENOMEM;
+		else
+			err = PTR_ERR(macsec_fs);
 		goto err_out;
+	}
 
 	macsec->macsec_fs = macsec_fs;