diff mbox series

[net-next] net/mlx5: SF, silence an uninitialized variable warning

Message ID 20211127141953.GD24002@kili (mailing list archive)
State Awaiting Upstream
Delegated to: Netdev Maintainers
Headers show
Series [net-next] net/mlx5: SF, silence an uninitialized variable warning | expand

Checks

Context Check Description
netdev/tree_selection success Clearly marked for net-next
netdev/fixes_present success Fixes tag not required for -next series
netdev/subject_prefix success Link
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: 0 this patch: 0
netdev/cc_maintainers success CCed 8 of 8 maintainers
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/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 0 this patch: 0
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 8 lines checked
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

Dan Carpenter Nov. 27, 2021, 2:19 p.m. UTC
This code sometimes calls mlx5_sf_hw_table_hwc_init() when "ext_base_id"
is uninitialized.  It's not used on that path, but it generates a static
checker warning to pass uninitialized variables to another function.
It may also generate runtime UBSan  warnings depending on if the
mlx5_sf_hw_table_hwc_init() function is inlined or not.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
 drivers/net/ethernet/mellanox/mlx5/core/sf/hw_table.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Leon Romanovsky Nov. 28, 2021, 9:26 a.m. UTC | #1
On Sat, Nov 27, 2021 at 05:19:53PM +0300, Dan Carpenter wrote:
> This code sometimes calls mlx5_sf_hw_table_hwc_init() when "ext_base_id"
> is uninitialized.  It's not used on that path, but it generates a static
> checker warning to pass uninitialized variables to another function.
> It may also generate runtime UBSan  warnings depending on if the
> mlx5_sf_hw_table_hwc_init() function is inlined or not.
> 
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> ---
>  drivers/net/ethernet/mellanox/mlx5/core/sf/hw_table.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

Thanks,
Reviewed-by: Leon Romanovsky <leonro@nvidia.com>
Saeed Mahameed Dec. 2, 2021, 6:28 a.m. UTC | #2
On Sun, 2021-11-28 at 11:26 +0200, Leon Romanovsky wrote:
> On Sat, Nov 27, 2021 at 05:19:53PM +0300, Dan Carpenter wrote:
> > This code sometimes calls mlx5_sf_hw_table_hwc_init() when
> > "ext_base_id"
> > is uninitialized.  It's not used on that path, but it generates a
> > static
> > checker warning to pass uninitialized variables to another
> > function.
> > It may also generate runtime UBSan  warnings depending on if the
> > mlx5_sf_hw_table_hwc_init() function is inlined or not.
> > 
> > Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> > ---
> >  drivers/net/ethernet/mellanox/mlx5/core/sf/hw_table.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> Thanks,
> Reviewed-by: Leon Romanovsky <leonro@nvidia.com>

applied to net-next-mlx5.
diff mbox series

Patch

diff --git a/drivers/net/ethernet/mellanox/mlx5/core/sf/hw_table.c b/drivers/net/ethernet/mellanox/mlx5/core/sf/hw_table.c
index 252d6017387d..17aa348989cb 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/sf/hw_table.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/sf/hw_table.c
@@ -247,7 +247,7 @@  int mlx5_sf_hw_table_init(struct mlx5_core_dev *dev)
 {
 	struct mlx5_sf_hw_table *table;
 	u16 max_ext_fn = 0;
-	u16 ext_base_id;
+	u16 ext_base_id = 0;
 	u16 max_fn = 0;
 	u16 base_id;
 	int err;