All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Bryn M. Reeves" <breeves@redhat.com>
To: device-mapper development <dm-devel@redhat.com>
Subject: [PATCH] dm-mpath-rdac.c init race
Date: Tue, 02 Oct 2007 16:07:32 +0100	[thread overview]
Message-ID: <47025EB4.9030801@redhat.com> (raw)

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

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

The current dm-mpath-rdac has a race in the init function since the hw
handler is registered with DM core before allocating the workqueue.

This patch just re-orders the allocation to be before the call to
dm_register_hw_handler and adds calls to destroys the workqueue in error
paths.

Cheers,
Bryn.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.7 (GNU/Linux)
Comment: Using GnuPG with Fedora - http://enigmail.mozdev.org

iD8DBQFHAl606YSQoMYUY94RAoyvAJ44CB5yY5B+6y66c7DgL/nFId+jcgCgwWYX
rh+hKlNANqNZRw6KkyrYCL0=
=mzHx
-----END PGP SIGNATURE-----

[-- Attachment #2: rdac-init-race.patch --]
[-- Type: text/x-patch, Size: 1155 bytes --]

Re-order the initialisation of dm-rdac to avoid registering the hw
handler before the workqueue has been initialised. Closes a race
that would potentially give an oops.

Signed-off-by: Bryn M. Reeves <breeves@redhat.com>

diff --git a/drivers/md/Makefile b/drivers/md/Makefile
diff --git a/drivers/md/dm-mpath-rdac.c b/drivers/md/dm-mpath-rdac.c
index 16b1613..a3d9d67 100644
--- a/drivers/md/dm-mpath-rdac.c
+++ b/drivers/md/dm-mpath-rdac.c
@@ -664,20 +664,21 @@ static struct hw_handler_type rdac_handler = {
 
 static int __init rdac_init(void)
 {
-	int r = dm_register_hw_handler(&rdac_handler);
-
-	if (r < 0) {
-		DMERR("%s: register failed %d", RDAC_DM_HWH_NAME, r);
-		return r;
-	}
+	int r;	
 
 	rdac_wkqd = create_singlethread_workqueue("rdac_wkqd");
 	if (!rdac_wkqd) {
 		DMERR("Failed to create workqueue rdac_wkqd.");
-		dm_unregister_hw_handler(&rdac_handler);
 		return -ENOMEM;
 	}
 
+	r = dm_register_hw_handler(&rdac_handler);
+	if (r < 0) {
+		DMERR("%s: register failed %d", RDAC_DM_HWH_NAME, r);
+		destroy_workqueue(rdac_wkqd);
+		return r;
+	}
+
 	DMINFO("%s: version %s loaded", RDAC_DM_HWH_NAME, RDAC_DM_HWH_VER);
 	return 0;
 }

[-- Attachment #3: Type: text/plain, Size: 0 bytes --]



                 reply	other threads:[~2007-10-02 15:07 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=47025EB4.9030801@redhat.com \
    --to=breeves@redhat.com \
    --cc=dm-devel@redhat.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.