Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 6e88e672 authored by Daniel Jurgens's avatar Daniel Jurgens Committed by Jason Gunthorpe
Browse files

IB/core: Fix potential memory leak while creating MAD agents



If the MAD agents isn't allowed to manage the subnet, or fails to register
for the LSM notifier, the security context is leaked. Free the context in
these cases.

Fixes: 47a2b338 ("IB/core: Enforce security on management datagrams")
Signed-off-by: default avatarDaniel Jurgens <danielj@mellanox.com>
Reviewed-by: default avatarParav Pandit <parav@mellanox.com>
Reported-by: default avatarParav Pandit <parav@mellanox.com>
Signed-off-by: default avatarLeon Romanovsky <leonro@mellanox.com>
Signed-off-by: default avatarJason Gunthorpe <jgg@mellanox.com>
parent d60667fc
Loading
Loading
Loading
Loading
+6 −2
Original line number Diff line number Diff line
@@ -710,16 +710,20 @@ int ib_mad_agent_security_setup(struct ib_mad_agent *agent,
						dev_name(&agent->device->dev),
						agent->port_num);
	if (ret)
		return ret;
		goto free_security;

	agent->lsm_nb.notifier_call = ib_mad_agent_security_change;
	ret = register_lsm_notifier(&agent->lsm_nb);
	if (ret)
		return ret;
		goto free_security;

	agent->smp_allowed = true;
	agent->lsm_nb_reg = true;
	return 0;

free_security:
	security_ib_free_security(agent->security);
	return ret;
}

void ib_mad_agent_security_cleanup(struct ib_mad_agent *agent)