Skip to content
Snippets Groups Projects
Commit 8036e90f authored by Parvi Kaustubhi's avatar Parvi Kaustubhi Committed by Jason Gunthorpe
Browse files

IB/usnic: Fix potential deadlock


Acquiring the rtnl lock while holding usdev_lock could result in a
deadlock.

For example:

usnic_ib_query_port()
| mutex_lock(&us_ibdev->usdev_lock)
 | ib_get_eth_speed()
  | rtnl_lock()

rtnl_lock()
| usnic_ib_netdevice_event()
 | mutex_lock(&us_ibdev->usdev_lock)

This commit moves the usdev_lock acquisition after the rtnl lock has been
released.

This is safe to do because usdev_lock is not protecting anything being
accessed in ib_get_eth_speed(). Hence, the correct order of holding locks
(rtnl -> usdev_lock) is not violated.

Signed-off-by: default avatarParvi Kaustubhi <pkaustub@cisco.com>
Signed-off-by: default avatarJason Gunthorpe <jgg@mellanox.com>
parent 50c582de
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment