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

Commit 3154ed36 authored by Sudarshan Rajagopalan's avatar Sudarshan Rajagopalan Committed by Gerrit - the friendly Code Review server
Browse files

ashmem: add mutex to set size ioctl



The ioctl of ashmem is an unlocked method, hence each of its command
functions must have its own locking. Since asma->size is used at different
critical sections, it must remain unchanged until the end of the critical
section that is being executed.

Change-Id: I804604667a25976334c174ba33601bed35df3755
Signed-off-by: default avatarSudarshan Rajagopalan <sudaraja@codeaurora.org>
parent fa403c81
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -766,10 +766,12 @@ static long ashmem_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
		break;
	case ASHMEM_SET_SIZE:
		ret = -EINVAL;
		mutex_lock(&ashmem_mutex);
		if (!asma->file) {
			ret = 0;
			asma->size = (size_t)arg;
		}
		mutex_unlock(&ashmem_mutex);
		break;
	case ASHMEM_GET_SIZE:
		ret = asma->size;