]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blame - releases/4.14.117/ib-core-fix-potential-memory-leak-while-creating-mad-agents.patch
Fixes for 4.19
[thirdparty/kernel/stable-queue.git] / releases / 4.14.117 / ib-core-fix-potential-memory-leak-while-creating-mad-agents.patch
CommitLineData
c728510a
GKH
1From 6e88e672b69f0e627acdae74a527b730ea224b6b Mon Sep 17 00:00:00 2001
2From: Daniel Jurgens <danielj@mellanox.com>
3Date: Sat, 2 Feb 2019 11:09:43 +0200
4Subject: IB/core: Fix potential memory leak while creating MAD agents
5
6From: Daniel Jurgens <danielj@mellanox.com>
7
8commit 6e88e672b69f0e627acdae74a527b730ea224b6b upstream.
9
10If the MAD agents isn't allowed to manage the subnet, or fails to register
11for the LSM notifier, the security context is leaked. Free the context in
12these cases.
13
14Fixes: 47a2b338fe63 ("IB/core: Enforce security on management datagrams")
15Signed-off-by: Daniel Jurgens <danielj@mellanox.com>
16Reviewed-by: Parav Pandit <parav@mellanox.com>
17Reported-by: Parav Pandit <parav@mellanox.com>
18Signed-off-by: Leon Romanovsky <leonro@mellanox.com>
19Signed-off-by: Jason Gunthorpe <jgg@mellanox.com>
20Signed-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)