mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: BlaisorBlade <blaisorblade_spam@yahoo.it>
To: linux-kernel@vger.kernel.org
Cc: akpm@osdl.org
Subject: [PATCH] loop.c doesn't fail init gracefully
Date: Wed, 24 Dec 2003 13:26:41 +0100	[thread overview]
Message-ID: <200312241257.06579.blaisorblade_spam@yahoo.it> (raw)

[-- Attachment #1: Type: text/plain, Size: 553 bytes --]

THIS PATCH:
loop_init doesn't fail gracefully for two reasons:
1)If initialization of loop driver fails, we have an call to devfs_add("loop") 
without any devfs_remove; I add that.
2) On lwn.net 2.6 kernel docs, Jonathan Corbet says:
"If you are calling add_disk() in your driver initialization routine, you 
should not fail the initialization process after the first call."

So I make loop.c conform to this request by moving add_disk after all memory 
allocations.
CC me on reply as I'm not subscribed, please.
-- 
Paolo Giarrusso, aka Blaisorblade



[-- Attachment #2: B-01-Loop_loadFailed_fix.patch --]
[-- Type: text/x-diff, Size: 608 bytes --]

--- ./drivers/block/loop.c.nofix	2003-12-11 19:37:08.000000000 +0100
+++ ./drivers/block/loop.c	2003-12-11 19:46:43.000000000 +0100
@@ -1212,14 +1212,18 @@
 		sprintf(disk->devfs_name, "loop/%d", i);
 		disk->private_data = lo;
 		disk->queue = lo->lo_queue;
-		add_disk(disk);
 	}
+
+	/* We cannot fail after we call this, so another loop!*/
+	for (i = 0; i < max_loop; i++)
+		add_disk(disks[i]);
 	printk(KERN_INFO "loop: loaded (max %d devices)\n", max_loop);
 	return 0;
 
 out_mem4:
 	while (i--)
 		blk_put_queue(loop_dev[i].lo_queue);
+	devfs_remove("loop");
 	i = max_loop;
 out_mem3:
 	while (i--)

             reply	other threads:[~2003-12-24 17:34 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-12-24 12:26 BlaisorBlade [this message]
2004-02-01 19:01 BlaisorBlade

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=200312241257.06579.blaisorblade_spam@yahoo.it \
    --to=blaisorblade_spam@yahoo.it \
    --cc=akpm@osdl.org \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®