ceph-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] rbd: avoid double free memory on error path in rbd_dev_create()
@ 2023-02-03 14:15 Natalia Petrova
  2023-02-06 11:58 ` Ilya Dryomov
  0 siblings, 1 reply; 6+ messages in thread
From: Natalia Petrova @ 2023-02-03 14:15 UTC (permalink / raw)
  To: Ilya Dryomov
  Cc: Natalia Petrova, Dongsheng Yang, Jens Axboe, ceph-devel,
	linux-block, linux-kernel, lvc-project, Alexey Khoroshilov

If rbd_dev_create() fails after assignment 'opts' to 'rbd_dev->opts',
double free of 'rbd_options' happens:
one is in rbd_dev_free() and another one is in do_rbd_add().

Found by Linux Verification Center (linuxtesting.org) with SVACE.

Fixes: 1643dfa4c2c8 ("rbd: introduce a per-device ordered workqueue")
Signed-off-by: Natalia Petrova <n.petrova@fintech.ru>
Signed-off-by: Alexey Khoroshilov <khoroshilov@ispras.ru>
---
 drivers/block/rbd.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c
index 04453f4a319c..ab6bfc352cde 100644
--- a/drivers/block/rbd.c
+++ b/drivers/block/rbd.c
@@ -5357,7 +5357,6 @@ static struct rbd_device *rbd_dev_create(struct rbd_client *rbdc,
 	if (!rbd_dev)
 		return NULL;
 
-	rbd_dev->opts = opts;
 
 	/* get an id and fill in device name */
 	rbd_dev->dev_id = ida_simple_get(&rbd_dev_id_ida, 0,
@@ -5372,6 +5371,7 @@ static struct rbd_device *rbd_dev_create(struct rbd_client *rbdc,
 	if (!rbd_dev->task_wq)
 		goto fail_dev_id;
 
+	rbd_dev->opts = opts;
 	/* we have a ref from do_rbd_add() */
 	__module_get(THIS_MODULE);
 
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2023-02-11  9:41 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-02-03 14:15 [PATCH] rbd: avoid double free memory on error path in rbd_dev_create() Natalia Petrova
2023-02-06 11:58 ` Ilya Dryomov
2023-02-06 15:15   ` Петрова Наталия Михайловна
2023-02-07  0:54     ` Xiubo Li
2023-02-09 12:09       ` [PATCH v2] rbd: fix freeing memory of 'rbd_dev->opts', 'rbd_dev->spec', 'rbd_dev->rbd_client' Natalia Petrova
2023-02-11  9:40         ` Ilya Dryomov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).