Skip to contentSkip to conversation

drbd: Fix double free problem in drbd_create_device

PATCH Applied Wu Bo 3 participants 3 messages Nov 4, 2021

Subsystems (2)
lore
Share & tools
lore

Wu Bo

author
#0 lore raw

PATCH 1/1 drbd: Fix double free problem in drbd_create_device

In drbd_create_device(), the 'out_no_io_page' lable has called blk_cleanup_disk() when return failed.

So remove the 'out_cleanup_disk' lable to avoid double free the disk pointer.

Fixes e92ab4eda516 ("drbd: add error handling support for add_disk()")
---
 drivers/block/drbd/drbd_main.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/block/drbd/drbd_main.c +1 -3
index 19db80a..53ba2dd 100644
@@ -2796,7 +2796,7 @@ enum drbd_ret_code drbd_create_device(struct drbd_config_context *adm_ctx, unsig
 
 	err = add_disk(disk);
 	if (err)
-		goto out_cleanup_disk;
+		goto out_idr_remove_vol;
 
 	/* inherit the connection state */
 	device->state.conn = first_connection(resource)->cstate;
@@ -2810,8 +2810,6 @@ enum drbd_ret_code drbd_create_device(struct drbd_config_context *adm_ctx, unsig
 	drbd_debugfs_device_add(device);
 	return NO_ERROR;
 
-out_cleanup_disk:
-	blk_cleanup_disk(disk);
 out_idr_remove_vol:
 	idr_remove(&connection->peer_devices, vnr);
 out_idr_remove_from_resource:
Signature · 1 line
1.8.3.1
maintainer Applied
#2 lore raw
In reply to Wu Bo
Quoted 8 lines · Wu Bo

In drbd_create_device(), the 'out_no_io_page' lable has called blk_cleanup_disk() when return failed.

So remove the 'out_cleanup_disk' lable to avoid double free the disk pointer.

[...]

Applied, thanks!

[1/1] drbd: Fix double free problem in drbd_create_device

      commit: 27548088ac628109f70eb0b1eb521d035844dba8

Best regards,

Signature · 1 line
Jens Axboe