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>

authored by Tilman Schmidt and committed by Linus Torvalds 5d49c101 1d6789c3

+4 -2
+4 -2
drivers/isdn/gigaset/common.c
··· 637 err("maximum number of devices exceeded"); 638 return NULL; 639 } 640 - mutex_init(&cs->mutex); 641 642 gig_dbg(DEBUG_INIT, "allocating bcs[0..%d]", channels - 1); 643 cs->bcs = kmalloc(channels * sizeof(struct bc_state), GFP_KERNEL); ··· 897 { 898 mutex_lock(&cs->mutex); 899 900 - if (!(cs->flags & VALID_MINOR)) 901 return -1; 902 903 cs->waiting = 1; 904 ··· 1087 drv->cs[i].driver = drv; 1088 drv->cs[i].ops = drv->ops; 1089 drv->cs[i].minor_index = i; 1090 } 1091 1092 gigaset_if_initdriver(drv, procname, devname);
··· 637 err("maximum number of devices exceeded"); 638 return NULL; 639 } 640 641 gig_dbg(DEBUG_INIT, "allocating bcs[0..%d]", channels - 1); 642 cs->bcs = kmalloc(channels * sizeof(struct bc_state), GFP_KERNEL); ··· 898 { 899 mutex_lock(&cs->mutex); 900 901 + if (!(cs->flags & VALID_MINOR)) { 902 + mutex_unlock(&cs->mutex); 903 return -1; 904 + } 905 906 cs->waiting = 1; 907 ··· 1086 drv->cs[i].driver = drv; 1087 drv->cs[i].ops = drv->ops; 1088 drv->cs[i].minor_index = i; 1089 + mutex_init(&drv->cs[i].mutex); 1090 } 1091 1092 gigaset_if_initdriver(drv, procname, devname);