Skip to contentSkip to conversation

drbd: Balance RCU calls in drbd_adm_dump_devices()

PATCH Applied Bart Van Assche 2 participants 3 messages Mar 26

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 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.

Cc Andreas Gruenbacher <[email protected]>
Fixes a55bbd375d18 ("drbd: Backport the "status" command")
---
 drivers/block/drbd/drbd_nl.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
drivers/block/drbd/drbd_nl.c +6 -2
index e18fa260a662..1f8ffdf9b24e 100644
@@ -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;
 	}
#1 lore raw
Quoted 3 lines · Bart Van Assche

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.

(replying to my own email)

Since it is the third time this patch is posted, the changelog is as follows:

Changes compared to v2:
- Added Christoph Hellwig's Reviewed-by tag.
- Extracted this patch from a larger series.

Changes compared to v1:
- Added Christoph Böhmwalder's Tested-by tag.

Bart.

maintainer Applied
#2 lore raw
In reply to Bart Van Assche
Quoted 3 lines · Bart Van Assche

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.

Applied, thanks!

[1/1] drbd: Balance RCU calls in drbd_adm_dump_devices()

      commit: 2b31e86387e60b3689339f0f0fbb4d3623d9d494

Best regards,

Signature · 1 line
Jens Axboe