* [PATCH 0/4] mailbox: A few fixes due for the v4.5-rc's
@ 2016-01-14 7:11 Lee Jones
2016-01-14 7:11 ` [PATCH 1/4] mailbox: mailbox-test: Use more consistent format for calling copy_from_user() Lee Jones
` (3 more replies)
0 siblings, 4 replies; 6+ messages in thread
From: Lee Jones @ 2016-01-14 7:11 UTC (permalink / raw)
To: linux-arm-kernel
Hi Jassi,
I assume you already have your pull-request set for the v4.5
merge window, so please take this and add them to your -fixes
branch.
Kind regards,
Lee
Lee Jones (4):
mailbox: mailbox-test: Use more consistent format for calling
copy_from_user()
mailbox: mailbox-test: Remove unused variable
mailbox: mailbox-test: Prevent memory leak
mailbox: Stop using ENOSYS for anything other than unimplemented
syscalls
drivers/mailbox/mailbox-test.c | 16 +++++++++-------
drivers/mailbox/mailbox.c | 4 ++--
2 files changed, 11 insertions(+), 9 deletions(-)
--
1.9.1
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH 1/4] mailbox: mailbox-test: Use more consistent format for calling copy_from_user()
2016-01-14 7:11 [PATCH 0/4] mailbox: A few fixes due for the v4.5-rc's Lee Jones
@ 2016-01-14 7:11 ` Lee Jones
2016-01-28 4:24 ` Jassi Brar
2016-01-14 7:11 ` [PATCH 2/4] mailbox: mailbox-test: Remove unused variable Lee Jones
` (2 subsequent siblings)
3 siblings, 1 reply; 6+ messages in thread
From: Lee Jones @ 2016-01-14 7:11 UTC (permalink / raw)
To: linux-arm-kernel
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>
---
drivers/mailbox/mailbox-test.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/mailbox/mailbox-test.c b/drivers/mailbox/mailbox-test.c
index 684ae17..7d9b915 100644
--- a/drivers/mailbox/mailbox-test.c
+++ b/drivers/mailbox/mailbox-test.c
@@ -63,9 +63,9 @@ 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;
}
--
1.9.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH 2/4] mailbox: mailbox-test: Remove unused variable
2016-01-14 7:11 [PATCH 0/4] mailbox: A few fixes due for the v4.5-rc's Lee Jones
2016-01-14 7:11 ` [PATCH 1/4] mailbox: mailbox-test: Use more consistent format for calling copy_from_user() Lee Jones
@ 2016-01-14 7:11 ` Lee Jones
2016-01-14 7:11 ` [PATCH 3/4] mailbox: mailbox-test: Prevent memory leak Lee Jones
2016-01-14 7:11 ` [PATCH 4/4] mailbox: Stop using ENOSYS for anything other than unimplemented syscalls Lee Jones
3 siblings, 0 replies; 6+ messages in thread
From: Lee Jones @ 2016-01-14 7:11 UTC (permalink / raw)
To: linux-arm-kernel
Even before it was unused, it always returned zero anyway.
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Lee Jones <lee.jones@linaro.org>
---
drivers/mailbox/mailbox-test.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/drivers/mailbox/mailbox-test.c b/drivers/mailbox/mailbox-test.c
index 7d9b915..e370aa6 100644
--- a/drivers/mailbox/mailbox-test.c
+++ b/drivers/mailbox/mailbox-test.c
@@ -45,7 +45,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");
@@ -69,7 +68,7 @@ static ssize_t mbox_test_signal_write(struct file *filp,
return -EFAULT;
}
- return ret < 0 ? ret : count;
+ return count;
}
static const struct file_operations mbox_test_signal_ops = {
--
1.9.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH 3/4] mailbox: mailbox-test: Prevent memory leak
2016-01-14 7:11 [PATCH 0/4] mailbox: A few fixes due for the v4.5-rc's Lee Jones
2016-01-14 7:11 ` [PATCH 1/4] mailbox: mailbox-test: Use more consistent format for calling copy_from_user() Lee Jones
2016-01-14 7:11 ` [PATCH 2/4] mailbox: mailbox-test: Remove unused variable Lee Jones
@ 2016-01-14 7:11 ` Lee Jones
2016-01-14 7:11 ` [PATCH 4/4] mailbox: Stop using ENOSYS for anything other than unimplemented syscalls Lee Jones
3 siblings, 0 replies; 6+ messages in thread
From: Lee Jones @ 2016-01-14 7:11 UTC (permalink / raw)
To: linux-arm-kernel
If we set the Signal twice or more, without using it as part of a message,
memory will be re-allocated and the pointer over-written. Prevent this
potential leak by only allocating memory when there isn't any already.
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Lee Jones <lee.jones@linaro.org>
---
drivers/mailbox/mailbox-test.c | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/drivers/mailbox/mailbox-test.c b/drivers/mailbox/mailbox-test.c
index e370aa6..539d475 100644
--- a/drivers/mailbox/mailbox-test.c
+++ b/drivers/mailbox/mailbox-test.c
@@ -58,9 +58,12 @@ 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;
+ }
if (copy_from_user(tdev->signal, userbuf, count)) {
kfree(tdev->signal);
--
1.9.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH 4/4] mailbox: Stop using ENOSYS for anything other than unimplemented syscalls
2016-01-14 7:11 [PATCH 0/4] mailbox: A few fixes due for the v4.5-rc's Lee Jones
` (2 preceding siblings ...)
2016-01-14 7:11 ` [PATCH 3/4] mailbox: mailbox-test: Prevent memory leak Lee Jones
@ 2016-01-14 7:11 ` Lee Jones
3 siblings, 0 replies; 6+ messages in thread
From: Lee Jones @ 2016-01-14 7:11 UTC (permalink / raw)
To: linux-arm-kernel
In accordance with e15f431fe2d5 ("errno.h: Improve ENOSYS's comment") and
91c9afaf97ee ("checkpatch.pl: new instances of ENOSYS are errors") we're
converting from the old meaning of: ENOSYS "Function not implemented" to
a more standard EINVAL.
Reported-by: Seraphin Bonnaffe <seraphin.bonnaffe@st.com>
Signed-off-by: Lee Jones <lee.jones@linaro.org>
---
drivers/mailbox/mailbox.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/mailbox/mailbox.c b/drivers/mailbox/mailbox.c
index 6a4811f..4a36632 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,
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) {
--
1.9.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH 1/4] mailbox: mailbox-test: Use more consistent format for calling copy_from_user()
2016-01-14 7:11 ` [PATCH 1/4] mailbox: mailbox-test: Use more consistent format for calling copy_from_user() Lee Jones
@ 2016-01-28 4:24 ` Jassi Brar
0 siblings, 0 replies; 6+ messages in thread
From: Jassi Brar @ 2016-01-28 4:24 UTC (permalink / raw)
To: linux-arm-kernel
On Thu, Jan 14, 2016 at 12:41 PM, Lee Jones <lee.jones@linaro.org> wrote:
> 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>
> ---
> drivers/mailbox/mailbox-test.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/mailbox/mailbox-test.c b/drivers/mailbox/mailbox-test.c
> index 684ae17..7d9b915 100644
> --- a/drivers/mailbox/mailbox-test.c
> +++ b/drivers/mailbox/mailbox-test.c
> @@ -63,9 +63,9 @@ 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;
> }
>
The function is left to return based on an uninitialized variable
('ret' on stack), so please merge this and the patch 2/4.
Thanks.
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2016-01-28 4:24 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-01-14 7:11 [PATCH 0/4] mailbox: A few fixes due for the v4.5-rc's Lee Jones
2016-01-14 7:11 ` [PATCH 1/4] mailbox: mailbox-test: Use more consistent format for calling copy_from_user() Lee Jones
2016-01-28 4:24 ` Jassi Brar
2016-01-14 7:11 ` [PATCH 2/4] mailbox: mailbox-test: Remove unused variable Lee Jones
2016-01-14 7:11 ` [PATCH 3/4] mailbox: mailbox-test: Prevent memory leak Lee Jones
2016-01-14 7:11 ` [PATCH 4/4] mailbox: Stop using ENOSYS for anything other than unimplemented syscalls Lee Jones
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).