diff options
author | Jiri Pirko | 2022-07-25 10:29:14 +0200 |
---|---|---|
committer | Jakub Kicinski | 2022-07-26 13:50:50 -0700 |
commit | 30bab7cdb56da4819ff081ad658646f2df16c098 (patch) | |
tree | 09aceb019193f4ecb67cb92ae460d122b3583a9d /net/caif | |
parent | 35d099da41967f114c6472b838e12014706c26e7 (diff) |
net: devlink: make sure that devlink_try_get() works with valid pointer during xarray iteration
Remove dependency on devlink_mutex during devlinks xarray iteration.
The reason is that devlink_register/unregister() functions taking
devlink_mutex would deadlock during devlink reload operation of devlink
instance which registers/unregisters nested devlink instances.
The devlinks xarray consistency is ensured internally by xarray.
There is a reference taken when working with devlink using
devlink_try_get(). But there is no guarantee that devlink pointer
picked during xarray iteration is not freed before devlink_try_get()
is called.
Make sure that devlink_try_get() works with valid pointer.
Achieve it by:
1) Splitting devlink_put() so the completion is sent only
after grace period. Completion unblocks the devlink_unregister()
routine, which is followed-up by devlink_free()
2) During devlinks xa_array iteration, get devlink pointer from xa_array
holding RCU read lock and taking reference using devlink_try_get()
before unlock.
Signed-off-by: Jiri Pirko <jiri@nvidia.com>
Reviewed-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Diffstat (limited to 'net/caif')
0 files changed, 0 insertions, 0 deletions