diff options
| author | Dmitry Torokhov <[email protected]> | 2023-08-30 16:06:38 -0700 | 
|---|---|---|
| committer | Dmitry Torokhov <[email protected]> | 2023-08-30 16:06:38 -0700 | 
| commit | 1ac731c529cd4d6adbce134754b51ff7d822b145 (patch) | |
| tree | 143ab3f35ca5f3b69f583c84e6964b17139c2ec1 /drivers/mailbox/mailbox-test.c | |
| parent | 07b4c950f27bef0362dc6ad7ee713aab61d58149 (diff) | |
| parent | 54116d442e001e1b6bd482122043b1870998a1f3 (diff) | |
Merge branch 'next' into for-linus
Prepare input updates for 6.6 merge window.
Diffstat (limited to 'drivers/mailbox/mailbox-test.c')
| -rw-r--r-- | drivers/mailbox/mailbox-test.c | 14 | 
1 files changed, 12 insertions, 2 deletions
diff --git a/drivers/mailbox/mailbox-test.c b/drivers/mailbox/mailbox-test.c index 4555d678fadd..fc6a12a51b40 100644 --- a/drivers/mailbox/mailbox-test.c +++ b/drivers/mailbox/mailbox-test.c @@ -12,10 +12,12 @@  #include <linux/kernel.h>  #include <linux/mailbox_client.h>  #include <linux/module.h> +#include <linux/mutex.h>  #include <linux/of.h>  #include <linux/platform_device.h>  #include <linux/poll.h>  #include <linux/slab.h> +#include <linux/spinlock.h>  #include <linux/uaccess.h>  #include <linux/sched/signal.h> @@ -38,6 +40,7 @@ struct mbox_test_device {  	char			*signal;  	char			*message;  	spinlock_t		lock; +	struct mutex		mutex;  	wait_queue_head_t	waitq;  	struct fasync_struct	*async_queue;  	struct dentry		*root_debugfs_dir; @@ -95,6 +98,7 @@ static ssize_t mbox_test_message_write(struct file *filp,  				       size_t count, loff_t *ppos)  {  	struct mbox_test_device *tdev = filp->private_data; +	char *message;  	void *data;  	int ret; @@ -110,10 +114,13 @@ static ssize_t mbox_test_message_write(struct file *filp,  		return -EINVAL;  	} -	tdev->message = kzalloc(MBOX_MAX_MSG_LEN, GFP_KERNEL); -	if (!tdev->message) +	message = kzalloc(MBOX_MAX_MSG_LEN, GFP_KERNEL); +	if (!message)  		return -ENOMEM; +	mutex_lock(&tdev->mutex); + +	tdev->message = message;  	ret = copy_from_user(tdev->message, userbuf, count);  	if (ret) {  		ret = -EFAULT; @@ -144,6 +151,8 @@ out:  	kfree(tdev->message);  	tdev->signal = NULL; +	mutex_unlock(&tdev->mutex); +  	return ret < 0 ? ret : count;  } @@ -392,6 +401,7 @@ static int mbox_test_probe(struct platform_device *pdev)  	platform_set_drvdata(pdev, tdev);  	spin_lock_init(&tdev->lock); +	mutex_init(&tdev->mutex);  	if (tdev->rx_channel) {  		tdev->rx_buffer = devm_kzalloc(&pdev->dev,  |