diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2016-04-14 21:40:47 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2016-04-14 21:40:47 -0400 |
commit | a7109a2ca79ce868620db3fff884277084a9d646 (patch) | |
tree | bcd5e80449ecd37ac4742b98cb9b41277f1c7825 /drivers/mailbox | |
parent | dfe70581c1b7a7625baa6ba26f8876d337845a23 (diff) | |
parent | 0c44d7896cbf9156b8bb10da4f665005622235ae (diff) |
Merge branch 'mailbox-devel' of git://git.linaro.org/landing-teams/working/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
Diffstat (limited to 'drivers/mailbox')
-rw-r--r-- | drivers/mailbox/mailbox-test.c | 16 | ||||
-rw-r--r-- | drivers/mailbox/mailbox-xgene-slimpro.c | 4 | ||||
-rw-r--r-- | drivers/mailbox/mailbox.c | 4 |
3 files changed, 13 insertions, 11 deletions
diff --git a/drivers/mailbox/mailbox-test.c b/drivers/mailbox/mailbox-test.c index dc11bbf27274..58d04726cdd7 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"); |
@@ -60,17 +59,20 @@ static ssize_t mbox_test_signal_write(struct file *filp, | |||
60 | return -EINVAL; | 59 | return -EINVAL; |
61 | } | 60 | } |
62 | 61 | ||
63 | tdev->signal = kzalloc(MBOX_MAX_SIG_LEN, GFP_KERNEL); | 62 | /* Only allocate memory if we need to */ |
64 | if (!tdev->signal) | 63 | if (!tdev->signal) { |
65 | return -ENOMEM; | 64 | tdev->signal = kzalloc(MBOX_MAX_SIG_LEN, GFP_KERNEL); |
65 | if (!tdev->signal) | ||
66 | return -ENOMEM; | ||
67 | } | ||
66 | 68 | ||
67 | ret = copy_from_user(tdev->signal, userbuf, count); | 69 | if (copy_from_user(tdev->signal, userbuf, count)) { |
68 | if (ret) { | ||
69 | kfree(tdev->signal); | 70 | kfree(tdev->signal); |
71 | tdev->signal = NULL; | ||
70 | return -EFAULT; | 72 | return -EFAULT; |
71 | } | 73 | } |
72 | 74 | ||
73 | return ret < 0 ? ret : count; | 75 | return count; |
74 | } | 76 | } |
75 | 77 | ||
76 | static const struct file_operations mbox_test_signal_ops = { | 78 | static const struct file_operations mbox_test_signal_ops = { |
diff --git a/drivers/mailbox/mailbox-xgene-slimpro.c b/drivers/mailbox/mailbox-xgene-slimpro.c index bd07f39f0692..dd2afbca51c9 100644 --- a/drivers/mailbox/mailbox-xgene-slimpro.c +++ b/drivers/mailbox/mailbox-xgene-slimpro.c | |||
@@ -189,8 +189,8 @@ static int slimpro_mbox_probe(struct platform_device *pdev) | |||
189 | int i; | 189 | int i; |
190 | 190 | ||
191 | ctx = devm_kzalloc(&pdev->dev, sizeof(struct slimpro_mbox), GFP_KERNEL); | 191 | ctx = devm_kzalloc(&pdev->dev, sizeof(struct slimpro_mbox), GFP_KERNEL); |
192 | if (IS_ERR(ctx)) | 192 | if (!ctx) |
193 | return PTR_ERR(ctx); | 193 | return -ENOMEM; |
194 | 194 | ||
195 | platform_set_drvdata(pdev, ctx); | 195 | platform_set_drvdata(pdev, ctx); |
196 | 196 | ||
diff --git a/drivers/mailbox/mailbox.c b/drivers/mailbox/mailbox.c index 6a4811f85705..4a36632c236f 100644 --- a/drivers/mailbox/mailbox.c +++ b/drivers/mailbox/mailbox.c | |||
@@ -375,13 +375,13 @@ struct mbox_chan *mbox_request_channel_byname(struct mbox_client *cl, | |||
375 | 375 | ||
376 | if (!np) { | 376 | if (!np) { |
377 | dev_err(cl->dev, "%s() currently only supports DT\n", __func__); | 377 | dev_err(cl->dev, "%s() currently only supports DT\n", __func__); |
378 | return ERR_PTR(-ENOSYS); | 378 | return ERR_PTR(-EINVAL); |
379 | } | 379 | } |
380 | 380 | ||
381 | if (!of_get_property(np, "mbox-names", NULL)) { | 381 | if (!of_get_property(np, "mbox-names", NULL)) { |
382 | dev_err(cl->dev, | 382 | dev_err(cl->dev, |
383 | "%s() requires an \"mbox-names\" property\n", __func__); | 383 | "%s() requires an \"mbox-names\" property\n", __func__); |
384 | return ERR_PTR(-ENOSYS); | 384 | return ERR_PTR(-EINVAL); |
385 | } | 385 | } |
386 | 386 | ||
387 | of_property_for_each_string(np, "mbox-names", prop, mbox_name) { | 387 | of_property_for_each_string(np, "mbox-names", prop, mbox_name) { |