]>
Commit | Line | Data |
---|---|---|
a65d4bac GKH |
1 | From foo@baz Sat Jul 28 10:25:26 CEST 2018 |
2 | From: Leon Romanovsky <leonro@mellanox.com> | |
3 | Date: Tue, 29 May 2018 14:56:19 +0300 | |
4 | Subject: RDMA/mad: Convert BUG_ONs to error flows | |
5 | ||
6 | From: Leon Romanovsky <leonro@mellanox.com> | |
7 | ||
8 | [ Upstream commit 2468b82d69e3a53d024f28d79ba0fdb8bf43dfbf ] | |
9 | ||
10 | Let's perform checks in-place instead of BUG_ONs. | |
11 | ||
12 | Signed-off-by: Leon Romanovsky <leonro@mellanox.com> | |
13 | Signed-off-by: Doug Ledford <dledford@redhat.com> | |
14 | Signed-off-by: Sasha Levin <alexander.levin@microsoft.com> | |
15 | Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> | |
16 | --- | |
17 | drivers/infiniband/core/mad.c | 11 +++++++---- | |
18 | 1 file changed, 7 insertions(+), 4 deletions(-) | |
19 | ||
20 | --- a/drivers/infiniband/core/mad.c | |
21 | +++ b/drivers/infiniband/core/mad.c | |
22 | @@ -1558,7 +1558,8 @@ static int add_oui_reg_req(struct ib_mad | |
23 | mad_reg_req->oui, 3)) { | |
24 | method = &(*vendor_table)->vendor_class[ | |
25 | vclass]->method_table[i]; | |
26 | - BUG_ON(!*method); | |
27 | + if (!*method) | |
28 | + goto error3; | |
29 | goto check_in_use; | |
30 | } | |
31 | } | |
32 | @@ -1568,10 +1569,12 @@ static int add_oui_reg_req(struct ib_mad | |
33 | vclass]->oui[i])) { | |
34 | method = &(*vendor_table)->vendor_class[ | |
35 | vclass]->method_table[i]; | |
36 | - BUG_ON(*method); | |
37 | /* Allocate method table for this OUI */ | |
38 | - if ((ret = allocate_method_table(method))) | |
39 | - goto error3; | |
40 | + if (!*method) { | |
41 | + ret = allocate_method_table(method); | |
42 | + if (ret) | |
43 | + goto error3; | |
44 | + } | |
45 | memcpy((*vendor_table)->vendor_class[vclass]->oui[i], | |
46 | mad_reg_req->oui, 3); | |
47 | goto check_in_use; |