Skip to content

Commit

Permalink
mailbox: mailbox-test: Use more consistent format for calling copy_fr…
Browse files Browse the repository at this point in the history
…om_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>
  • Loading branch information
Lee Jones authored and Jassi Brar committed Apr 12, 2016
1 parent a61b37e commit 17f5f28
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions drivers/mailbox/mailbox-test.c
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ static ssize_t mbox_test_signal_write(struct file *filp,
size_t count, loff_t *ppos)
{
struct mbox_test_device *tdev = filp->private_data;
int ret;

if (!tdev->tx_channel) {
dev_err(tdev->dev, "Channel cannot do Tx\n");
Expand All @@ -64,13 +63,13 @@ static ssize_t mbox_test_signal_write(struct file *filp,
if (!tdev->signal)
return -ENOMEM;

ret = copy_from_user(tdev->signal, userbuf, count);
if (ret) {
if (copy_from_user(tdev->signal, userbuf, count)) {
kfree(tdev->signal);
tdev->signal = NULL;
return -EFAULT;
}

return ret < 0 ? ret : count;
return count;
}

static const struct file_operations mbox_test_signal_ops = {
Expand Down

0 comments on commit 17f5f28

Please sign in to comment.