Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1535607 > unrolled thread
| Started by | Pan Bian <bianpan201604@163.com> |
|---|---|
| First post | 2016-12-04 07:30 +0100 |
| Last post | 2016-12-05 21:00 +0100 |
| Articles | 3 — 3 participants |
Back to article view | Back to linux.kernel
[PATCH 1/1] net: ethernet: broadcom: fix improper return value Pan Bian <bianpan201604@163.com> - 2016-12-04 07:30 +0100
RE: [PATCH 1/1] net: ethernet: broadcom: fix improper return value "Kalderon, Michal" <Michal.Kalderon@cavium.com> - 2016-12-04 12:40 +0100
Re: [PATCH 1/1] net: ethernet: broadcom: fix improper return value David Miller <davem@davemloft.net> - 2016-12-05 21:00 +0100
| From | Pan Bian <bianpan201604@163.com> |
|---|---|
| Date | 2016-12-04 07:30 +0100 |
| Subject | [PATCH 1/1] net: ethernet: broadcom: fix improper return value |
| Message-ID | <sKytb-3Dx-19@gated-at.bofh.it> |
From: Pan Bian <bianpan2016@163.com> Marco 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> --- drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c index 0cee4c0..6f9fc20 100644 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c @@ -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 */ -- 1.9.1
[toc] | [next] | [standalone]
| From | "Kalderon, Michal" <Michal.Kalderon@cavium.com> |
|---|---|
| Date | 2016-12-04 12:40 +0100 |
| Message-ID | <sKDjb-6yS-3@gated-at.bofh.it> |
| In reply to | #1535607 |
> From: Pan Bian <bianpan2016@163.com> > > Marco 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> The title is wrong from net-next; It should have been "bnx2x: Fix improper return value". Acked-by: Michal Kalderon <michal.kalderon@cavium.com>
[toc] | [prev] | [next] | [standalone]
| From | David Miller <davem@davemloft.net> |
|---|---|
| Date | 2016-12-05 21:00 +0100 |
| Message-ID | <sL7AB-kR-15@gated-at.bofh.it> |
| In reply to | #1535607 |
From: Pan Bian <bianpan201604@163.com> Date: Sun, 4 Dec 2016 14:29:29 +0800 > From: Pan Bian <bianpan2016@163.com> > > Marco 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> Applied, but... > @@ -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 */ These kinds of macros which internally change control flow should always be avoided.
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web