From: Dan Carpenter <dan.carpenter@oracle.com>
To: Jassi Brar <jassisinghbrar@gmail.com>, Lee Jones <lee.jones@linaro.org>
Cc: linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org
Subject: [patch] mailbox: Off by one in mbox_test_message_read()
Date: Thu, 22 Oct 2015 19:51:27 +0000 [thread overview]
Message-ID: <20151022195127.GA24439@mwanda> (raw)
We need to leave space for the NUL char.
Fixes: 8ea4484d0c2b ('mailbox: Add generic mechanism for testing Mailbox Controllers')
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
Btw, if we fill up the entire buffer then we don't copy the last NUL to
the user.
diff --git a/drivers/mailbox/mailbox-test.c b/drivers/mailbox/mailbox-test.c
index 22f2e40..feff8fb 100644
--- a/drivers/mailbox/mailbox-test.c
+++ b/drivers/mailbox/mailbox-test.c
@@ -142,7 +142,7 @@ static ssize_t mbox_test_message_read(struct file *filp, char __user *userbuf,
int l = 0;
int ret;
- touser = kzalloc(MBOX_HEXDUMP_MAX_LEN, GFP_KERNEL);
+ touser = kzalloc(MBOX_HEXDUMP_MAX_LEN + 1, GFP_KERNEL);
if (!touser)
return -ENOMEM;
reply other threads:[~2015-10-22 19:51 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20151022195127.GA24439@mwanda \
--to=dan.carpenter@oracle.com \
--cc=jassisinghbrar@gmail.com \
--cc=kernel-janitors@vger.kernel.org \
--cc=lee.jones@linaro.org \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox