Skip to content

Commit

Permalink
gigaset: fix Oops on module unload regression
Browse files Browse the repository at this point in the history
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
e468c04 ("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>
  • Loading branch information
tilmanschmidt authored and Linus Torvalds committed Mar 7, 2008
1 parent 1d6789c commit 5d49c10
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions drivers/isdn/gigaset/common.c
Original file line number Diff line number Diff line change
Expand Up @@ -637,7 +637,6 @@ struct cardstate *gigaset_initcs(struct gigaset_driver *drv, int channels,
err("maximum number of devices exceeded");
return NULL;
}
mutex_init(&cs->mutex);

gig_dbg(DEBUG_INIT, "allocating bcs[0..%d]", channels - 1);
cs->bcs = kmalloc(channels * sizeof(struct bc_state), GFP_KERNEL);
Expand Down Expand Up @@ -898,8 +897,10 @@ int gigaset_shutdown(struct cardstate *cs)
{
mutex_lock(&cs->mutex);

if (!(cs->flags & VALID_MINOR))
if (!(cs->flags & VALID_MINOR)) {
mutex_unlock(&cs->mutex);
return -1;
}

cs->waiting = 1;

Expand Down Expand Up @@ -1086,6 +1087,7 @@ struct gigaset_driver *gigaset_initdriver(unsigned minor, unsigned minors,
drv->cs[i].driver = drv;
drv->cs[i].ops = drv->ops;
drv->cs[i].minor_index = i;
mutex_init(&drv->cs[i].mutex);
}

gigaset_if_initdriver(drv, procname, devname);
Expand Down

0 comments on commit 5d49c10

Please sign in to comment.