Skip to content

Commit

Permalink
Merge branch 'mailbox-devel' of git://git.linaro.org/landing-teams/wo…
Browse files Browse the repository at this point in the history
…rking/fujitsu/integration

Pull mailbox fixes from Jussi Brar:
 "Misc fixes:

  mailbox-test driver:
   - prevent memory leak and another cosmetic change

  mailbox:
   - change the returned error code

  Xgene driver:
   - return -ENOMEM instead of PTR_ERR for failed devm_kzalloc"

* 'mailbox-devel' of git://git.linaro.org/landing-teams/working/fujitsu/integration:
  mailbox: Stop using ENOSYS for anything other than unimplemented syscalls
  mailbox: mailbox-test: Prevent memory leak
  mailbox: mailbox-test: Use more consistent format for calling copy_from_user()
  mailbox: xgene-slimpro: Fix wrong test for devm_kzalloc
  • Loading branch information
Linus Torvalds committed Apr 15, 2016
2 parents dfe7058 + 0c44d78 commit a7109a2
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 11 deletions.
16 changes: 9 additions & 7 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 @@ -60,17 +59,20 @@ static ssize_t mbox_test_signal_write(struct file *filp,
return -EINVAL;
}

tdev->signal = kzalloc(MBOX_MAX_SIG_LEN, GFP_KERNEL);
if (!tdev->signal)
return -ENOMEM;
/* Only allocate memory if we need to */
if (!tdev->signal) {
tdev->signal = kzalloc(MBOX_MAX_SIG_LEN, GFP_KERNEL);
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
4 changes: 2 additions & 2 deletions drivers/mailbox/mailbox-xgene-slimpro.c
Original file line number Diff line number Diff line change
Expand Up @@ -189,8 +189,8 @@ static int slimpro_mbox_probe(struct platform_device *pdev)
int i;

ctx = devm_kzalloc(&pdev->dev, sizeof(struct slimpro_mbox), GFP_KERNEL);
if (IS_ERR(ctx))
return PTR_ERR(ctx);
if (!ctx)
return -ENOMEM;

platform_set_drvdata(pdev, ctx);

Expand Down
4 changes: 2 additions & 2 deletions drivers/mailbox/mailbox.c
Original file line number Diff line number Diff line change
Expand Up @@ -375,13 +375,13 @@ struct mbox_chan *mbox_request_channel_byname(struct mbox_client *cl,

if (!np) {
dev_err(cl->dev, "%s() currently only supports DT\n", __func__);
return ERR_PTR(-ENOSYS);
return ERR_PTR(-EINVAL);
}

if (!of_get_property(np, "mbox-names", NULL)) {
dev_err(cl->dev,
"%s() requires an \"mbox-names\" property\n", __func__);
return ERR_PTR(-ENOSYS);
return ERR_PTR(-EINVAL);
}

of_property_for_each_string(np, "mbox-names", prop, mbox_name) {
Expand Down

0 comments on commit a7109a2

Please sign in to comment.