summaryrefslogtreecommitdiff
path: root/sound/sound_core.c
diff options
context:
space:
mode:
authorScott Wood <scottwood@freescale.com>2014-04-07 23:49:35 (GMT)
committerScott Wood <scottwood@freescale.com>2014-04-07 23:49:35 (GMT)
commit62b8c978ee6b8d135d9e7953221de58000dba986 (patch)
tree683b04b2e627f6710c22c151b23c8cc9a165315e /sound/sound_core.c
parent78fd82238d0e5716578c326404184a27ba67fd6e (diff)
downloadlinux-fsl-qoriq-62b8c978ee6b8d135d9e7953221de58000dba986.tar.xz
Rewind v3.13-rc3+ (78fd82238d0e5716) to v3.12
Diffstat (limited to 'sound/sound_core.c')
-rw-r--r--sound/sound_core.c17
1 files changed, 14 insertions, 3 deletions
diff --git a/sound/sound_core.c b/sound/sound_core.c
index 11e953a..45759f4 100644
--- a/sound/sound_core.c
+++ b/sound/sound_core.c
@@ -626,20 +626,31 @@ static int soundcore_open(struct inode *inode, struct file *file)
if (s)
new_fops = fops_get(s->unit_fops);
}
- spin_unlock(&sound_loader_lock);
if (new_fops) {
/*
* We rely upon the fact that we can't be unloaded while the
- * subdriver is there.
+ * subdriver is there, so if ->open() is successful we can
+ * safely drop the reference counter and if it is not we can
+ * revert to old ->f_op. Ugly, indeed, but that's the cost of
+ * switching ->f_op in the first place.
*/
int err = 0;
- replace_fops(file, new_fops);
+ const struct file_operations *old_fops = file->f_op;
+ file->f_op = new_fops;
+ spin_unlock(&sound_loader_lock);
if (file->f_op->open)
err = file->f_op->open(inode,file);
+ if (err) {
+ fops_put(file->f_op);
+ file->f_op = fops_get(old_fops);
+ }
+
+ fops_put(old_fops);
return err;
}
+ spin_unlock(&sound_loader_lock);
return -ENODEV;
}