IPoIB: Fix crash when path record fails after path flush
authorRoland Dreier <rolandd@cisco.com>
Thu, 25 Sep 2008 22:28:08 +0000 (15:28 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Thu, 25 Sep 2008 23:37:03 +0000 (16:37 -0700)
commit6ef190cc92e33565accff6a320f0e7d90480bfe7
treeb898c20fa9baba3a10ba03b5a64911bd3c8416f1
parentefba91bd9066890ae93270eb3d0e55de43368f0b
IPoIB: Fix crash when path record fails after path flush

Commit ee1e2c82 ("IPoIB: Refresh paths instead of flushing them on SM
change events") changed how paths are flushed on an SM event.  This
change introduces a problem if the path record query triggered by
fails, causing path->ah to become NULL.  A later successful path query
will then trigger WARN_ON() in path_rec_completion(), and crash
because path->ah has already been freed, so the ipoib_put_ah() inside
the lock in path_rec_completion() may actually drop the last reference
(contrary to the comment that claims this is safe).

Fix this by updating path->ah and freeing old_ah only when the path
record query is successful.  This prevents the neighbour AH and that
path AH from getting out of sync.

This fixes <https://bugs.openfabrics.org/show_bug.cgi?id=1194>

Reported-by: Rabah Salem <ravah@mellanox.com>
Debugged-by: Eli Cohen <eli@mellanox.co.il>
Signed-off-by: Roland Dreier <rolandd@cisco.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
drivers/infiniband/ulp/ipoib/ipoib_main.c