From 5cfc86a07a661552eef70ec708027c8a39f7e6fa Mon Sep 17 00:00:00 2001 From: Shengjiu Wang Date: Mon, 7 Aug 2017 17:21:09 +0800 Subject: MLK-16154: ASoC: fsl_asrc_m2m: fix crash issue with multi-instance When open 2 instances of m2m, there is kernel dump. The reason is we use the dev_set_drvdata to set drvdata for each instance, but each instance share a same device, the result is drvdata will be changed by other instances, then cause issue. so the dev_set_drvdata can't be used, need to combine the pair data with file handler. Fixes: 58ab1eb5b8c5 ("MLK-13945-3: ASoC: fsl_asrc: support two asrc devices") Signed-off-by: Shengjiu Wang --- sound/soc/fsl/fsl_asrc_m2m.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'sound/soc/fsl/fsl_asrc_m2m.c') diff --git a/sound/soc/fsl/fsl_asrc_m2m.c b/sound/soc/fsl/fsl_asrc_m2m.c index 14877b43c4e1..e1b347801688 100644 --- a/sound/soc/fsl/fsl_asrc_m2m.c +++ b/sound/soc/fsl/fsl_asrc_m2m.c @@ -761,8 +761,7 @@ static long fsl_asrc_ioctl_flush(struct fsl_asrc_pair *pair, void __user *user) static long fsl_asrc_ioctl(struct file *file, unsigned int cmd, unsigned long arg) { - struct miscdevice *asrc_miscdev = file->private_data; - struct fsl_asrc_pair *pair = dev_get_drvdata(asrc_miscdev->this_device); + struct fsl_asrc_pair *pair = file->private_data; struct fsl_asrc *asrc_priv = pair->asrc_priv; void __user *user = (void __user *)arg; long ret = 0; @@ -833,7 +832,7 @@ static int fsl_asrc_open(struct inode *inode, struct file *file) spin_lock_init(&m2m->lock); - dev_set_drvdata(asrc_miscdev->this_device, pair); + file->private_data = pair; pm_runtime_get_sync(dev); @@ -846,8 +845,7 @@ out: static int fsl_asrc_close(struct inode *inode, struct file *file) { - struct miscdevice *asrc_miscdev = file->private_data; - struct fsl_asrc_pair *pair = dev_get_drvdata(asrc_miscdev->this_device); + struct fsl_asrc_pair *pair = file->private_data; struct fsl_asrc_m2m *m2m = pair->private; struct fsl_asrc *asrc_priv = pair->asrc_priv; struct device *dev = &asrc_priv->pdev->dev; @@ -885,6 +883,7 @@ static int fsl_asrc_close(struct inode *inode, struct file *file) kfree(m2m); kfree(pair); spin_unlock_irqrestore(&asrc_priv->lock, lock_flags); + file->private_data = NULL; pm_runtime_put_sync(dev); -- cgit v1.2.3