Commit fbb8b6ef authored by Neil Brown's avatar Neil Brown Committed by Adrian Bunk

Fix a potential NULL dereference in md/raid1

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.
Signed-off-by: default avatarNeil Brown <neilb@suse.de>
Signed-off-by: default avatarAdrian Bunk <bunk@stusta.de>
parent 13967acc
...@@ -1467,7 +1467,6 @@ static void raid1d(mddev_t *mddev) ...@@ -1467,7 +1467,6 @@ static void raid1d(mddev_t *mddev)
d = conf->raid_disks; d = conf->raid_disks;
d--; d--;
rdev = conf->mirrors[d].rdev; rdev = conf->mirrors[d].rdev;
atomic_add(s, &rdev->corrected_errors);
if (rdev && if (rdev &&
test_bit(In_sync, &rdev->flags)) { test_bit(In_sync, &rdev->flags)) {
if (sync_page_io(rdev->bdev, if (sync_page_io(rdev->bdev,
...@@ -1490,6 +1489,9 @@ static void raid1d(mddev_t *mddev) ...@@ -1490,6 +1489,9 @@ static void raid1d(mddev_t *mddev)
s<<9, conf->tmppage, READ) == 0) s<<9, conf->tmppage, READ) == 0)
/* Well, this device is dead */ /* Well, this device is dead */
md_error(mddev, rdev); md_error(mddev, rdev);
else
atomic_add(s, &rdev->corrected_errors);
} }
} }
} else { } else {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment