Skip to content

Commit

Permalink
net: bnx2x: fix improper return value
Browse files Browse the repository at this point in the history
Macro BNX2X_ALLOC_AND_SET(arr, lbl, func) calls kmalloc() to allocate
memory, and jumps to label "lbl" if the allocation fails. Label "lbl"
first cleans memory and then returns variable rc. Before calling the
macro, the value of variable rc is 0. Because 0 means no error, the
callers of bnx2x_init_firmware() may be misled. This patch fixes the bug,
assigning "-ENOMEM" to rc before calling macro NX2X_ALLOC_AND_SET().

Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=189141

Signed-off-by: Pan Bian <bianpan2016@163.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Pan Bian authored and David S. Miller committed Dec 5, 2016
1 parent 0ff18d2 commit 005f7e6
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -13505,6 +13505,7 @@ static int bnx2x_init_firmware(struct bnx2x *bp)

/* Initialize the pointers to the init arrays */
/* Blob */
rc = -ENOMEM;
BNX2X_ALLOC_AND_SET(init_data, request_firmware_exit, be32_to_cpu_n);

/* Opcodes */
Expand Down

0 comments on commit 005f7e6

Please sign in to comment.