diff mbox series

[2/2] nbd: fix double lock for nbd->config_lock

Message ID 20201020081615.240305-3-xiubli@redhat.com (mailing list archive)
State New, archived
Headers show
Series nbd: fix use-after-freed and double lock bugs | expand

Commit Message

Xiubo Li Oct. 20, 2020, 8:16 a.m. UTC
From: Xiubo Li <xiubli@redhat.com>

When NBD_CLEAR_SOCK with ioctl method, it will double lock the
config_lock.

Signed-off-by: Xiubo Li <xiubli@redhat.com>
---
 drivers/block/nbd.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
diff mbox series

Patch

diff --git a/drivers/block/nbd.c b/drivers/block/nbd.c
index 3d3f4255e495..b21abf134e34 100644
--- a/drivers/block/nbd.c
+++ b/drivers/block/nbd.c
@@ -1358,9 +1358,7 @@  static void nbd_clear_sock_ioctl(struct nbd_device *nbd,
 	sock_shutdown(nbd);
 	__invalidate_device(bdev, true);
 	nbd_bdev_reset(bdev);
-	if (test_and_clear_bit(NBD_RT_HAS_CONFIG_REF,
-			       &nbd->config->runtime_flags))
-		nbd_config_put(nbd);
+	nbd_config_clear_rt_ref_and_put(nbd);
 }
 
 static bool nbd_is_valid_blksize(unsigned long blksize)