]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
drbd: Balance RCU calls in drbd_adm_dump_devices()
authorBart Van Assche <bvanassche@acm.org>
Thu, 26 Mar 2026 21:40:54 +0000 (14:40 -0700)
committerJens Axboe <axboe@kernel.dk>
Thu, 26 Mar 2026 22:04:52 +0000 (16:04 -0600)
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 <christoph.boehmwalder@linbit.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Cc: Andreas Gruenbacher <agruenba@redhat.com>
Fixes: a55bbd375d18 ("drbd: Backport the "status" command")
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
Link: https://patch.msgid.link/20260326214054.284593-1-bvanassche@acm.org
Signed-off-by: Jens Axboe <axboe@kernel.dk>
drivers/block/drbd/drbd_nl.c

index e18fa260a662581e8db9f47320bf53e185f7c228..1f8ffdf9b24ef83c28c721f6523fa5cf9fcc98d8 100644 (file)
@@ -3443,8 +3443,10 @@ int drbd_adm_dump_devices(struct sk_buff *skb, struct netlink_callback *cb)
                if (resource_filter) {
                        retcode = ERR_RES_NOT_KNOWN;
                        resource = drbd_find_resource(nla_data(resource_filter));
-                       if (!resource)
+                       if (!resource) {
+                               rcu_read_lock();
                                goto put_result;
+                       }
                        cb->args[0] = (long)resource;
                }
        }
@@ -3693,8 +3695,10 @@ int drbd_adm_dump_peer_devices(struct sk_buff *skb, struct netlink_callback *cb)
                if (resource_filter) {
                        retcode = ERR_RES_NOT_KNOWN;
                        resource = drbd_find_resource(nla_data(resource_filter));
-                       if (!resource)
+                       if (!resource) {
+                               rcu_read_lock();
                                goto put_result;
+                       }
                }
                cb->args[0] = (long)resource;
        }