mirror of
https://github.com/torvalds/linux.git
synced 2026-11-30 10:32:24 +00:00
Previously there was a race that could allow the mctp_dev refcount to hit zero: rcu_read_lock(); mdev = __mctp_dev_get(dev); // mctp_unregister() happens here, mdev->refs hits zero mctp_dev_hold(dev); rcu_read_unlock(); Now we make __mctp_dev_get() take the hold itself. It is safe to test against the zero refcount because __mctp_dev_get() is called holding rcu_read_lock and mctp_dev uses kfree_rcu(). Reported-by: Jakub Kicinski <[email protected]> Signed-off-by: Matt Johnston <[email protected]> Signed-off-by: David S. Miller <[email protected]>