Skip to contentSkip to conversation

Fix a bug in error path in alloc_dev

PATCH In review Ishai Rabinovitz 2 participants 2 messages Jul 16, 2006 Device mapper

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Fix a bug in error path in alloc_dev

Hi,

While reading the code I found a bug in the error path in alloc_dev in dm.c

When blk_alloc_queue fails there is no call to free_minor.

This patch fixes the problem.

drivers/md/dm.c +2 -1
Index: linux-2.6.18-devel/drivers/md/dm.c
===================================================================
@@ -903,7 +903,7 @@ static struct mapped_device *alloc_dev(i
 
 	md->queue = blk_alloc_queue(GFP_KERNEL);
 	if (!md->queue)
-		goto bad1;
+		goto bad1_free_minor;
 
 	md->queue->queuedata = md;
 	md->queue->backing_dev_info.congested_fn = dm_any_congested;
@@ -953,6 +953,7 @@ static struct mapped_device *alloc_dev(i
 	mempool_destroy(md->io_pool);
  bad2:
 	blk_cleanup_queue(md->queue);
+ bad1_free_minor:
 	free_minor(minor);
  bad1:
 	module_put(THIS_MODULE);
Signature · 1 line
Ishai Rabinovitz
#1 lore raw
Quoted 2 lines · Ishai Rabinovitz

While reading the code I found a bug in the error path in alloc_dev in dm.c When blk_alloc_queue fails there is no call to free_minor.

Well spotted!
[I don't like numbered labels BTW - the patch shows why.]

Alasdair

Signature · 1 line
[email protected]