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

Commit 64b784b5 authored by Ralph Campbell's avatar Ralph Campbell Committed by Roland Dreier
Browse files

IB/sa_query: Check if sm_ah is NULL in ib_sa_remove_one()



If update_sm_ah() fails, it leaves the port's sm_ah as NULL.  Then if
the device or module is removed, ib_sa_remove_one() will dereference a
NULL pointer when it calls kref_put().  Fix this by testing if sm_ah
is NULL before dropping the reference.

Signed-off-by: default avatarRalph Campbell <ralph.campbell@qlogic.com>
Signed-off-by: default avatarRoland Dreier <rolandd@cisco.com>
parent d35cb360
Loading
Loading
Loading
Loading
+2 −1
Original line number Original line Diff line number Diff line
@@ -1064,6 +1064,7 @@ static void ib_sa_remove_one(struct ib_device *device)


	for (i = 0; i <= sa_dev->end_port - sa_dev->start_port; ++i) {
	for (i = 0; i <= sa_dev->end_port - sa_dev->start_port; ++i) {
		ib_unregister_mad_agent(sa_dev->port[i].agent);
		ib_unregister_mad_agent(sa_dev->port[i].agent);
		if (sa_dev->port[i].sm_ah)
			kref_put(&sa_dev->port[i].sm_ah->ref, free_sm_ah);
			kref_put(&sa_dev->port[i].sm_ah->ref, free_sm_ah);
	}
	}