diff options
author | Tilman Schmidt <tilman@imap.cc> | 2008-03-07 13:47:08 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@woody.linux-foundation.org> | 2008-03-07 14:06:08 -0500 |
commit | 5d49c101a126808a38f2a1f4eedc1fd28233e37f (patch) | |
tree | b227dbfadf35428ea0db7cb071f5e33e22702682 | |
parent | 1d6789c3bc2b70bed1eb71aa616b1d94f9c23a63 (diff) |
gigaset: fix Oops on module unload regression
The card state mutex was only initialized when a device was connected,
but used during unload unconditionally, leading to an Oops if a driver
was loaded and unloaded again without ever connecting a device.
Fix this by initializing the mutex as soon as the structure is allocated.
Also add a missing mutex unlock revealed in the same execution path.
This fixes a possible Oops in 2.6.25-rc that was introduced by commit
e468c04894f36045cf93d1384183a461014b6840 ("Gigaset: permit module
unload").
Thanks to Roland Kletzing for reporting this problem.
Signed-off-by: Tilman Schmidt <tilman@imap.cc>
Tested-by: Roland Kletzing <devzero@web.de>
Cc: Hansjoerg Lipp <hjlipp@web.de>
Cc: Karsten Keil <kkeil@suse.de>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r-- | drivers/isdn/gigaset/common.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/drivers/isdn/gigaset/common.c b/drivers/isdn/gigaset/common.c index aacedec4986f..827c32c16795 100644 --- a/drivers/isdn/gigaset/common.c +++ b/drivers/isdn/gigaset/common.c | |||
@@ -637,7 +637,6 @@ struct cardstate *gigaset_initcs(struct gigaset_driver *drv, int channels, | |||
637 | err("maximum number of devices exceeded"); | 637 | err("maximum number of devices exceeded"); |
638 | return NULL; | 638 | return NULL; |
639 | } | 639 | } |
640 | mutex_init(&cs->mutex); | ||
641 | 640 | ||
642 | gig_dbg(DEBUG_INIT, "allocating bcs[0..%d]", channels - 1); | 641 | gig_dbg(DEBUG_INIT, "allocating bcs[0..%d]", channels - 1); |
643 | cs->bcs = kmalloc(channels * sizeof(struct bc_state), GFP_KERNEL); | 642 | cs->bcs = kmalloc(channels * sizeof(struct bc_state), GFP_KERNEL); |
@@ -898,8 +897,10 @@ int gigaset_shutdown(struct cardstate *cs) | |||
898 | { | 897 | { |
899 | mutex_lock(&cs->mutex); | 898 | mutex_lock(&cs->mutex); |
900 | 899 | ||
901 | if (!(cs->flags & VALID_MINOR)) | 900 | if (!(cs->flags & VALID_MINOR)) { |
901 | mutex_unlock(&cs->mutex); | ||
902 | return -1; | 902 | return -1; |
903 | } | ||
903 | 904 | ||
904 | cs->waiting = 1; | 905 | cs->waiting = 1; |
905 | 906 | ||
@@ -1086,6 +1087,7 @@ struct gigaset_driver *gigaset_initdriver(unsigned minor, unsigned minors, | |||
1086 | drv->cs[i].driver = drv; | 1087 | drv->cs[i].driver = drv; |
1087 | drv->cs[i].ops = drv->ops; | 1088 | drv->cs[i].ops = drv->ops; |
1088 | drv->cs[i].minor_index = i; | 1089 | drv->cs[i].minor_index = i; |
1090 | mutex_init(&drv->cs[i].mutex); | ||
1089 | } | 1091 | } |
1090 | 1092 | ||
1091 | gigaset_if_initdriver(drv, procname, devname); | 1093 | gigaset_if_initdriver(drv, procname, devname); |