From: Majd Dibbiny <[email protected]> When ib_register_mad_agent fails, it returns a pointer with error which is not NULL, therefore when calling ib_unregister_mad_agent we need to check that the passed mad_agent is valid and not erroneous.
Signed-off-by: Majd Dibbiny <[email protected]> Signed-off-by: Or Gerlitz <[email protected]> --- drivers/infiniband/core/mad.c | 4 ++++ 1 files changed, 4 insertions(+), 0 deletions(-) diff --git a/drivers/infiniband/core/mad.c b/drivers/infiniband/core/mad.c index 74c30f4..8ec811e 100644 --- a/drivers/infiniband/core/mad.c +++ b/drivers/infiniband/core/mad.c @@ -619,6 +619,9 @@ int ib_unregister_mad_agent(struct ib_mad_agent *mad_agent) struct ib_mad_agent_private *mad_agent_priv; struct ib_mad_snoop_private *mad_snoop_priv; + if (IS_ERR(mad_agent)) + goto out; + /* If the TID is zero, the agent can only snoop. */ if (mad_agent->hi_tid) { mad_agent_priv = container_of(mad_agent, @@ -631,6 +634,7 @@ int ib_unregister_mad_agent(struct ib_mad_agent *mad_agent) agent); unregister_mad_snoop(mad_snoop_priv); } +out: return 0; } EXPORT_SYMBOL(ib_unregister_mad_agent); -- 1.7.1 -- To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
