All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dan Carpenter <error27@gmail.com>
To: Joerg Roedel <joro@8bytes.org>
Cc: Joerg Roedel <joerg.roedel@amd.com>, Ingo Molnar <mingo@elte.hu>,
	FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>,
	Shaun Ruffell <sruffell@digium.com>,
	linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org
Subject: [patch v2] dma-debug: cleanup for loop
Date: Tue, 06 Apr 2010 16:45:12 +0000	[thread overview]
Message-ID: <20100406164512.GF21229@bicker> (raw)
In-Reply-To: <20100405140909.GB29758@8bytes.org>

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;

WARNING: multiple messages have this Message-ID (diff)
From: Dan Carpenter <error27@gmail.com>
To: Joerg Roedel <joro@8bytes.org>
Cc: Joerg Roedel <joerg.roedel@amd.com>, Ingo Molnar <mingo@elte.hu>,
	FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>,
	Shaun Ruffell <sruffell@digium.com>,
	linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org
Subject: [patch v2] dma-debug: cleanup for loop
Date: Tue, 6 Apr 2010 19:45:12 +0300	[thread overview]
Message-ID: <20100406164512.GF21229@bicker> (raw)
In-Reply-To: <20100405140909.GB29758@8bytes.org>

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;

  reply	other threads:[~2010-04-06 16:45 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-04-02 11:28 [patch] dma-debug: off by one issue Dan Carpenter
2010-04-02 11:28 ` Dan Carpenter
2010-04-03 20:47 ` Joerg Roedel
2010-04-03 20:47   ` Joerg Roedel
2010-04-05 12:53   ` Dan Carpenter
2010-04-05 12:53     ` Dan Carpenter
2010-04-05 14:02     ` Joerg Roedel
2010-04-05 14:02       ` Joerg Roedel
2010-04-05 14:09       ` Joerg Roedel
2010-04-05 14:09         ` Joerg Roedel
2010-04-06 16:45         ` Dan Carpenter [this message]
2010-04-06 16:45           ` [patch v2] dma-debug: cleanup for loop Dan Carpenter
2010-04-07 10:05           ` Joerg Roedel
2010-04-07 10:05             ` Joerg Roedel

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=20100406164512.GF21229@bicker \
    --to=error27@gmail.com \
    --cc=fujita.tomonori@lab.ntt.co.jp \
    --cc=joerg.roedel@amd.com \
    --cc=joro@8bytes.org \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=sruffell@digium.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.