Skip to contentSkip to conversation

Fix a potential NULL dereference in md/raid1

PATCH Applied NeilBrown 2 participants 2 messages Aug 21, 2006 1 message not in the archive MD RAID

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): 20060821100439.22490.patches@notabene

NeilBrown

author
#1 lore raw

PATCH 1/1 Fix a potential NULL dereference in md/raid1

patch for 2.6.17 stable series.
Thanks,
NeilBrown
### Comments for Changeset

At the point where this 'atomic_add' is, rdev could be NULL, as seen by the fact that we test for this in the very next statement.
Further is it is really the wrong place of the add. We could add to the count of corrected errors
once the are sure it was corrected, not before trying to correct it.

### Diffstat output

 ./drivers/md/raid1.c |    4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/md/raid1.c +3 -1
diff .prev/drivers/md/raid1.c ./drivers/md/raid1.c
@@ -1486,7 +1486,6 @@ static void raid1d(mddev_t *mddev)
 							d = conf->raid_disks;
 						d--;
 						rdev = conf->mirrors[d].rdev;
-						atomic_add(s, &rdev->corrected_errors);
 						if (rdev &&
 						    test_bit(In_sync, &rdev->flags)) {
 							if (sync_page_io(rdev->bdev,
@@ -1509,6 +1508,9 @@ static void raid1d(mddev_t *mddev)
 									 s<<9, conf->tmppage, READ) == 0)
 								/* Well, this device is dead */
 								md_error(mddev, rdev);
+							else
+								atomic_add(s, &rdev->corrected_errors);
+
 						}
 					}
 				} else {
Applied
#2 lore raw
Quoted 13 lines · NeilBrown

patch for 2.6.17 stable series.
Thanks,
NeilBrown
### Comments for Changeset

At the point where this 'atomic_add' is, rdev could be NULL, as seen by the fact that we test for this in the very next statement.
Further is it is really the wrong place of the add. We could add to the count of corrected errors
once the are sure it was corrected, not before trying to correct it.

Quoted 1 line

Queued for -stable, thanks.

greg k-h