linux-raid.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] md: do not use ++ in rcu_dereference() argument
@ 2010-09-05 18:32 Kulikov Vasiliy
  2010-09-05 19:01 ` Sam Ravnborg
  2010-09-06 20:10 ` Arnd Bergmann
  0 siblings, 2 replies; 20+ messages in thread
From: Kulikov Vasiliy @ 2010-09-05 18:32 UTC (permalink / raw)
  To: kernel-janitors
  Cc: Vasiliy Kulikov, Neil Brown, Jens Axboe, linux-raid, linux-kernel

From: Vasiliy Kulikov <segooon@gmail.com>

rcu_dereference() is macro, so it might use its argument twice.
Argument must not has side effects.

It was found by compiler warning:
drivers/md/raid1.c: In function ‘read_balance’:
drivers/md/raid1.c:445: warning: operation on ‘new_disk’ may be undefined

Signed-off-by: Vasiliy Kulikov <segooon@gmail.com>
---
 drivers/md/raid1.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c
index ad83a4d..12194df 100644
--- a/drivers/md/raid1.c
+++ b/drivers/md/raid1.c
@@ -442,7 +442,7 @@ static int read_balance(conf_t *conf, r1bio_t *r1_bio)
 		     r1_bio->bios[new_disk] == IO_BLOCKED ||
 		     !rdev || !test_bit(In_sync, &rdev->flags)
 			     || test_bit(WriteMostly, &rdev->flags);
-		     rdev = rcu_dereference(conf->mirrors[++new_disk].rdev)) {
+		     rdev = rcu_dereference(conf->mirrors[new_disk].rdev)) {
 
 			if (rdev && test_bit(In_sync, &rdev->flags) &&
 				r1_bio->bios[new_disk] != IO_BLOCKED)
@@ -452,6 +452,7 @@ static int read_balance(conf_t *conf, r1bio_t *r1_bio)
 				new_disk = wonly_disk;
 				break;
 			}
+			new_disk++;
 		}
 		goto rb_out;
 	}
-- 
1.7.0.4

^ permalink raw reply related	[flat|nested] 20+ messages in thread

end of thread, other threads:[~2010-09-17  3:18 UTC | newest]

Thread overview: 20+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-09-05 18:32 [PATCH] md: do not use ++ in rcu_dereference() argument Kulikov Vasiliy
2010-09-05 19:01 ` Sam Ravnborg
2010-09-05 19:23   ` Kulikov Vasiliy
2010-09-05 20:39     ` Sam Ravnborg
2010-09-06  5:29       ` Neil Brown
2010-09-06  7:43         ` walter harms
2010-09-06 11:05           ` Neil Brown
2010-09-06 19:21         ` Sam Ravnborg
2010-09-08  7:04           ` Neil Brown
2010-09-16 12:54         ` Avi Kivity
2010-09-17  3:18           ` Neil Brown
2010-09-06 20:10 ` Arnd Bergmann
2010-09-07 19:21   ` Kulikov Vasiliy
2010-09-07 20:00     ` Arnd Bergmann
2010-09-07 20:50       ` Paul E. McKenney
2010-09-09 15:14         ` Arnd Bergmann
2010-09-10  3:46           ` Paul E. McKenney
2010-09-14  0:33             ` Paul E. McKenney
2010-09-15 12:28               ` Arnd Bergmann
2010-09-16  6:15                 ` Paul E. McKenney

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).