Skip to content

Commit

Permalink
net: bnx2x: fix variable dereferenced before check
Browse files Browse the repository at this point in the history
Smatch says:
	bnx2x_init_ops.h:640 bnx2x_ilt_client_mem_op()
	warn: variable dereferenced before check 'ilt' (see line 638)

Move ilt_cli variable initialization _after_ ilt validation, because
it's unsafe to deref the pointer before validation check.

Fixes: 523224a ("bnx2x, cnic, bnx2i: use new FW/HSI")
Signed-off-by: Pavel Skripkin <paskripkin@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Pavel Skripkin authored and David S. Miller committed Nov 15, 2021
1 parent 2153bd1 commit f8885ac
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion drivers/net/ethernet/broadcom/bnx2x/bnx2x_init_ops.h
Original file line number Diff line number Diff line change
Expand Up @@ -635,11 +635,13 @@ static int bnx2x_ilt_client_mem_op(struct bnx2x *bp, int cli_num,
{
int i, rc;
struct bnx2x_ilt *ilt = BP_ILT(bp);
struct ilt_client_info *ilt_cli = &ilt->clients[cli_num];
struct ilt_client_info *ilt_cli;

if (!ilt || !ilt->lines)
return -1;

ilt_cli = &ilt->clients[cli_num];

if (ilt_cli->flags & (ILT_CLIENT_SKIP_INIT | ILT_CLIENT_SKIP_MEM))
return 0;

Expand Down

0 comments on commit f8885ac

Please sign in to comment.