Skip to content

Commit

Permalink
IB/core: Fix potential memory leak while creating MAD agents
Browse files Browse the repository at this point in the history
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: 47a2b33 ("IB/core: Enforce security on management datagrams")
Signed-off-by: Daniel Jurgens <[email protected]>
Reviewed-by: Parav Pandit <[email protected]>
Reported-by: Parav Pandit <[email protected]>
Signed-off-by: Leon Romanovsky <[email protected]>
Signed-off-by: Jason Gunthorpe <[email protected]>
  • Loading branch information
danielj-mellanox authored and jgunthorpe committed Feb 8, 2019
1 parent d60667f commit 6e88e67
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions drivers/infiniband/core/security.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 6e88e67

Please sign in to comment.