* [patch] mailbox: Off by one in mbox_test_message_read()
@ 2015-10-22 19:51 Dan Carpenter
0 siblings, 0 replies; only message in thread
From: Dan Carpenter @ 2015-10-22 19:51 UTC (permalink / raw)
To: Jassi Brar, Lee Jones; +Cc: linux-kernel, kernel-janitors
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;
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2015-10-22 19:51 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-10-22 19:51 [patch] mailbox: Off by one in mbox_test_message_read() Dan Carpenter
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).