Commit 77795318 authored by Pavel Andrianov's avatar Pavel Andrianov Committed by Greg Kroah-Hartman
Browse files

speakup: Add spinlock in synth_direct_store



All operations with synth buffer should be protected,
as there are global pointers, which should be modified atomically.

Found by Linux Driver Verification project (linuxtesting.org)

Signed-off-by: default avatarPavel Andrianov <andrianov@ispras.ru>
Acked-by: default avatarVaishali Thakkar <vaishali.thakkar@oracle.com>
Reviewed-by: default avatarSamuel Thibault <samuel.thibault@ens-lyon.org>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent da25a8ec
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -411,11 +411,13 @@ static ssize_t synth_direct_store(struct kobject *kobj,
	int len;
	int bytes;
	const char *ptr = buf;
	unsigned long flags;

	if (!synth)
		return -EPERM;

	len = strlen(buf);
	spin_lock_irqsave(&speakup_info.spinlock, flags);
	while (len > 0) {
		bytes = min_t(size_t, len, 250);
		strncpy(tmp, ptr, bytes);
@@ -425,6 +427,7 @@ static ssize_t synth_direct_store(struct kobject *kobj,
		ptr += bytes;
		len -= bytes;
	}
	spin_unlock_irqrestore(&speakup_info.spinlock, flags);
	return count;
}