]>
Commit | Line | Data |
---|---|---|
c728510a GKH |
1 | From 6e88e672b69f0e627acdae74a527b730ea224b6b Mon Sep 17 00:00:00 2001 |
2 | From: Daniel Jurgens <danielj@mellanox.com> | |
3 | Date: Sat, 2 Feb 2019 11:09:43 +0200 | |
4 | Subject: IB/core: Fix potential memory leak while creating MAD agents | |
5 | ||
6 | From: Daniel Jurgens <danielj@mellanox.com> | |
7 | ||
8 | commit 6e88e672b69f0e627acdae74a527b730ea224b6b upstream. | |
9 | ||
10 | If the MAD agents isn't allowed to manage the subnet, or fails to register | |
11 | for the LSM notifier, the security context is leaked. Free the context in | |
12 | these cases. | |
13 | ||
14 | Fixes: 47a2b338fe63 ("IB/core: Enforce security on management datagrams") | |
15 | Signed-off-by: Daniel Jurgens <danielj@mellanox.com> | |
16 | Reviewed-by: Parav Pandit <parav@mellanox.com> | |
17 | Reported-by: Parav Pandit <parav@mellanox.com> | |
18 | Signed-off-by: Leon Romanovsky <leonro@mellanox.com> | |
19 | Signed-off-by: Jason Gunthorpe <jgg@mellanox.com> | |
20 | Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> | |
21 | ||
22 | --- | |
23 | drivers/infiniband/core/security.c | 8 ++++++-- | |
24 | 1 file changed, 6 insertions(+), 2 deletions(-) | |
25 | ||
26 | --- a/drivers/infiniband/core/security.c | |
27 | +++ b/drivers/infiniband/core/security.c | |
28 | @@ -715,16 +715,20 @@ int ib_mad_agent_security_setup(struct i | |
29 | agent->device->name, | |
30 | agent->port_num); | |
31 | if (ret) | |
32 | - return ret; | |
33 | + goto free_security; | |
34 | ||
35 | agent->lsm_nb.notifier_call = ib_mad_agent_security_change; | |
36 | ret = register_lsm_notifier(&agent->lsm_nb); | |
37 | if (ret) | |
38 | - return ret; | |
39 | + goto free_security; | |
40 | ||
41 | agent->smp_allowed = true; | |
42 | agent->lsm_nb_reg = true; | |
43 | return 0; | |
44 | + | |
45 | +free_security: | |
46 | + security_ib_free_security(agent->security); | |
47 | + return ret; | |
48 | } | |
49 | ||
50 | void ib_mad_agent_security_cleanup(struct ib_mad_agent *agent) |