diff options
author | Lee Jones <lee.jones@linaro.org> | 2016-03-23 10:43:41 -0400 |
---|---|---|
committer | Jassi Brar <jaswinder.singh@linaro.org> | 2016-04-12 03:58:20 -0400 |
commit | 17f5f28ffa6e81461a569290ae802a9b05a89072 (patch) | |
tree | d13894a7a30fc57b2681661d980845ab20b08e31 | |
parent | a61b37ead51488e321fe559a4edd0325c6d4c937 (diff) |
mailbox: mailbox-test: Use more consistent format for calling copy_from_user()
While we're at it, ensure copy-to location is NULL'ed in the error path.
Suggested-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Lee Jones <lee.jones@linaro.org>
Signed-off-by: Jassi Brar <jaswinder.singh@linaro.org>
-rw-r--r-- | drivers/mailbox/mailbox-test.c | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/drivers/mailbox/mailbox-test.c b/drivers/mailbox/mailbox-test.c index dc11bbf27274..5f4b439fd45a 100644 --- a/drivers/mailbox/mailbox-test.c +++ b/drivers/mailbox/mailbox-test.c | |||
@@ -46,7 +46,6 @@ static ssize_t mbox_test_signal_write(struct file *filp, | |||
46 | size_t count, loff_t *ppos) | 46 | size_t count, loff_t *ppos) |
47 | { | 47 | { |
48 | struct mbox_test_device *tdev = filp->private_data; | 48 | struct mbox_test_device *tdev = filp->private_data; |
49 | int ret; | ||
50 | 49 | ||
51 | if (!tdev->tx_channel) { | 50 | if (!tdev->tx_channel) { |
52 | dev_err(tdev->dev, "Channel cannot do Tx\n"); | 51 | dev_err(tdev->dev, "Channel cannot do Tx\n"); |
@@ -64,13 +63,13 @@ static ssize_t mbox_test_signal_write(struct file *filp, | |||
64 | if (!tdev->signal) | 63 | if (!tdev->signal) |
65 | return -ENOMEM; | 64 | return -ENOMEM; |
66 | 65 | ||
67 | ret = copy_from_user(tdev->signal, userbuf, count); | 66 | if (copy_from_user(tdev->signal, userbuf, count)) { |
68 | if (ret) { | ||
69 | kfree(tdev->signal); | 67 | kfree(tdev->signal); |
68 | tdev->signal = NULL; | ||
70 | return -EFAULT; | 69 | return -EFAULT; |
71 | } | 70 | } |
72 | 71 | ||
73 | return ret < 0 ? ret : count; | 72 | return count; |
74 | } | 73 | } |
75 | 74 | ||
76 | static const struct file_operations mbox_test_signal_ops = { | 75 | static const struct file_operations mbox_test_signal_ops = { |