Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 794d2b5d authored by Linux Build Service Account's avatar Linux Build Service Account Committed by Gerrit - the friendly Code Review server
Browse files

Merge "ASoC: msm: qdspv2: add mutex lock when access output buffer length" into msm-4.9

parents 901005ef 6adc863d
Loading
Loading
Loading
Loading
+14 −0
Original line number Diff line number Diff line
@@ -29,6 +29,8 @@ struct q6audio_effects {
	struct audio_client             *ac;
	struct msm_hwacc_effects_config  config;

	struct mutex			lock;

	atomic_t			in_count;
	atomic_t			out_count;

@@ -231,8 +233,11 @@ static int audio_effects_shared_ioctl(struct file *file, unsigned int cmd,
		uint32_t idx = 0;
		uint32_t size = 0;

		mutex_lock(&effects->lock);

		if (!effects->started) {
			rc = -EFAULT;
			mutex_unlock(&effects->lock);
			goto ioctl_fail;
		}

@@ -242,11 +247,13 @@ static int audio_effects_shared_ioctl(struct file *file, unsigned int cmd,
		if (!rc) {
			pr_err("%s: write wait_event_timeout\n", __func__);
			rc = -EFAULT;
			 mutex_unlock(&effects->lock);
			goto ioctl_fail;
		}
		if (!atomic_read(&effects->out_count)) {
			pr_err("%s: pcm stopped out_count 0\n", __func__);
			rc = -EFAULT;
			mutex_unlock(&effects->lock);
			goto ioctl_fail;
		}

@@ -256,6 +263,7 @@ static int audio_effects_shared_ioctl(struct file *file, unsigned int cmd,
				copy_from_user(bufptr, (void *)arg,
					effects->config.buf_cfg.output_len)) {
				rc = -EFAULT;
				mutex_unlock(&effects->lock);
				goto ioctl_fail;
			}
			rc = q6asm_write(effects->ac,
@@ -263,6 +271,7 @@ static int audio_effects_shared_ioctl(struct file *file, unsigned int cmd,
					 0, 0, NO_TIMESTAMP);
			if (rc < 0) {
				rc = -EFAULT;
				mutex_unlock(&effects->lock);
				goto ioctl_fail;
			}
			atomic_dec(&effects->out_count);
@@ -270,6 +279,7 @@ static int audio_effects_shared_ioctl(struct file *file, unsigned int cmd,
			pr_err("%s: AUDIO_EFFECTS_WRITE: Buffer dropped\n",
				__func__);
		}
		mutex_unlock(&effects->lock);
		break;
	}
	case AUDIO_EFFECTS_READ: {
@@ -469,6 +479,7 @@ static long audio_effects_ioctl(struct file *file, unsigned int cmd,
		break;
	}
	case AUDIO_EFFECTS_SET_BUF_LEN: {
		mutex_lock(&effects->lock);
		if (copy_from_user(&effects->config.buf_cfg, (void *)arg,
				   sizeof(effects->config.buf_cfg))) {
			pr_err("%s: copy from user for AUDIO_EFFECTS_SET_BUF_LEN failed\n",
@@ -478,6 +489,7 @@ static long audio_effects_ioctl(struct file *file, unsigned int cmd,
		pr_debug("%s: write buf len: %d, read buf len: %d\n",
			 __func__, effects->config.buf_cfg.output_len,
			 effects->config.buf_cfg.input_len);
		mutex_unlock(&effects->lock);
		break;
	}
	case AUDIO_EFFECTS_GET_BUF_AVAIL: {
@@ -725,6 +737,7 @@ static int audio_effects_release(struct inode *inode, struct file *file)
	}
	q6asm_audio_client_free(effects->ac);

	mutex_destroy(&effects->lock);
	kfree(effects);

	pr_debug("%s: close session success\n", __func__);
@@ -752,6 +765,7 @@ static int audio_effects_open(struct inode *inode, struct file *file)

	init_waitqueue_head(&effects->read_wait);
	init_waitqueue_head(&effects->write_wait);
	mutex_init(&effects->lock);

	effects->opened = 0;
	effects->started = 0;