Thread (31 messages) 31 messages, 2 authors, 2021-02-02

[RFC PATCH 03/20] loop: add lockdep assert in loop_lookup()

flat view
STALE2093d

From: Chaitanya Kulkarni <hidden>
Date: 2021-02-02 05:37:28
Subsystem: block layer, the rest · Maintainers: Jens Axboe, Linus Torvalds

In current code loop_lookup() is called from loop_probe(),
and loop_control_ioctl(). Each of these functions hold global
mutex lock loop_ctrl_mutex with two variants mutex_lock() and
mutex_lock_killable().

Add lockdep_asset_lock_held() in loop_lookup() to make sure it will
generate an appropriate error message in case of misuse.  

Signed-off-by: Chaitanya Kulkarni <redacted>
---
 drivers/block/loop.c | 2 ++
 1 file changed, 2 insertions(+)
diff --git a/drivers/block/loop.c b/drivers/block/loop.c
index 3bfdcabaf6b1..0a8cee66c622 100644
--- a/drivers/block/loop.c
+++ b/drivers/block/loop.c
@@ -2211,6 +2211,8 @@ static int loop_lookup(struct loop_device **l, int i)
 	struct loop_device *lo;
 	int ret = -ENODEV;
 
+	lockdep_assert_held(&loop_ctl_mutex);
+
 	if (i < 0) {
 		int err;
 
-- 
2.22.1
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help