Re: [patch] dma-debug: off by one issue

Previous thread: [PATCH 0/1] perf newt: Zoom operations by Arnaldo Carvalho de Melo on Saturday, April 3, 2010 - 12:44 pm. (2 messages)

Next thread: [PATCH] staging: crystalhd: Fix for big-endian systems by leon.woestenberg on Saturday, April 3, 2010 - 2:22 pm. (1 message)
From: Joerg Roedel
Date: Saturday, April 3, 2010 - 1:47 pm

The character is already reserved by the user-to-kernel copy earlier in
the function.

--

From: Dan Carpenter
Date: Monday, April 5, 2010 - 5:53 am

Yes, but the original code requires more code reading to audit. Let's 
change the commit message to say that it's a clean up patch.

regards,
--

From: Joerg Roedel
Date: Monday, April 5, 2010 - 7:02 am

In this case its better to remove the

	current_driver_name[i] = 0;

line just after the loop.

	Joerg

--

From: Joerg Roedel
Date: Monday, April 5, 2010 - 7:09 am

Ah no, thats nonsense. Mind to resend the patch with a new
commit-message? I'll queue it then tomorrow.

	Joerg

--

From: Dan Carpenter
Subject:
Date: Tuesday, April 6, 2010 - 9:45 am

Earlier in this function we set the last byte of "buf" to NULL so we 
always hit the break statement and "i" is never equal to NAME_MAX_LEN.  
This patch doesn't change how the driver works but it silences a Smatch 
warning and it makes it clearer that we don't write past the end of the 
array.

Signed-off-by: Dan Carpenter <error27@gmail.com>

diff --git a/lib/dma-debug.c b/lib/dma-debug.c
index ba8b670..01e6427 100644
--- a/lib/dma-debug.c
+++ b/lib/dma-debug.c
@@ -570,7 +570,7 @@ static ssize_t filter_write(struct file *file, const char __user *userbuf,
 	 * Now parse out the first token and use it as the name for the
 	 * driver to filter for.
 	 */
-	for (i = 0; i < NAME_MAX_LEN; ++i) {
+	for (i = 0; i < NAME_MAX_LEN - 1; ++i) {
 		current_driver_name[i] = buf[i];
 		if (isspace(buf[i]) || buf[i] == ' ' || buf[i] == 0)
 			break;
--

From: Joerg Roedel
Date: Wednesday, April 7, 2010 - 3:05 am

Applied, thanks.


--

Previous thread: [PATCH 0/1] perf newt: Zoom operations by Arnaldo Carvalho de Melo on Saturday, April 3, 2010 - 12:44 pm. (2 messages)

Next thread: [PATCH] staging: crystalhd: Fix for big-endian systems by leon.woestenberg on Saturday, April 3, 2010 - 2:22 pm. (1 message)