mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-29 11:11:45 -04:00
FMC: fix locking in sample chardev driver
The fmc-chardev module was over-locking, by calling misc register/unregister while holding its spinlock. This reported a "scheduling while atomic" error. Since the misc driver already serializes operations internally, this commit downgrades the fmc-chardev lock to just cover its own list. Reported-by: Sasha Levin <[email protected]> Reported-by: Fengguang Wu <[email protected]> Signed-off-by: Alessandro Rubini <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
This commit is contained in:
parent
5f90b9b484
commit
783c2fb1b8
1 changed files with 4 additions and 5 deletions
|
|
@ -143,18 +143,17 @@ static int fc_probe(struct fmc_device *fmc)
|
|||
fc->misc.fops = &fc_fops;
|
||||
fc->misc.name = kstrdup(dev_name(&fmc->dev), GFP_KERNEL);
|
||||
|
||||
spin_lock(&fc_lock);
|
||||
ret = misc_register(&fc->misc);
|
||||
if (ret < 0)
|
||||
goto err_unlock;
|
||||
goto out;
|
||||
spin_lock(&fc_lock);
|
||||
list_add(&fc->list, &fc_devices);
|
||||
spin_unlock(&fc_lock);
|
||||
dev_info(&fc->fmc->dev, "Created misc device \"%s\"\n",
|
||||
fc->misc.name);
|
||||
return 0;
|
||||
|
||||
err_unlock:
|
||||
spin_unlock(&fc_lock);
|
||||
out:
|
||||
kfree(fc->misc.name);
|
||||
kfree(fc);
|
||||
return ret;
|
||||
|
|
@ -174,10 +173,10 @@ static int fc_remove(struct fmc_device *fmc)
|
|||
|
||||
spin_lock(&fc_lock);
|
||||
list_del(&fc->list);
|
||||
spin_unlock(&fc_lock);
|
||||
misc_deregister(&fc->misc);
|
||||
kfree(fc->misc.name);
|
||||
kfree(fc);
|
||||
spin_unlock(&fc_lock);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue