Skip to content

Commit 2b31e86

Browse files
bvanasscheaxboe
authored andcommitted
drbd: Balance RCU calls in drbd_adm_dump_devices()
Make drbd_adm_dump_devices() call rcu_read_lock() before rcu_read_unlock() is called. This has been detected by the Clang thread-safety analyzer. Tested-by: Christoph Böhmwalder <[email protected]> Reviewed-by: Christoph Hellwig <[email protected]> Cc: Andreas Gruenbacher <[email protected]> Fixes: a55bbd3 ("drbd: Backport the "status" command") Signed-off-by: Bart Van Assche <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Jens Axboe <[email protected]>
1 parent 630bbba commit 2b31e86

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

drivers/block/drbd/drbd_nl.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3443,8 +3443,10 @@ int drbd_adm_dump_devices(struct sk_buff *skb, struct netlink_callback *cb)
34433443
if (resource_filter) {
34443444
retcode = ERR_RES_NOT_KNOWN;
34453445
resource = drbd_find_resource(nla_data(resource_filter));
3446-
if (!resource)
3446+
if (!resource) {
3447+
rcu_read_lock();
34473448
goto put_result;
3449+
}
34483450
cb->args[0] = (long)resource;
34493451
}
34503452
}
@@ -3693,8 +3695,10 @@ int drbd_adm_dump_peer_devices(struct sk_buff *skb, struct netlink_callback *cb)
36933695
if (resource_filter) {
36943696
retcode = ERR_RES_NOT_KNOWN;
36953697
resource = drbd_find_resource(nla_data(resource_filter));
3696-
if (!resource)
3698+
if (!resource) {
3699+
rcu_read_lock();
36973700
goto put_result;
3701+
}
36983702
}
36993703
cb->args[0] = (long)resource;
37003704
}

0 commit comments

Comments
 (0)