]> git.ipfire.org Git - thirdparty/mdadm.git/commitdiff
Fix error in pol_sort.
authorNeilBrown <neilb@suse.de>
Mon, 22 Nov 2010 08:35:25 +0000 (19:35 +1100)
committerNeilBrown <neilb@suse.de>
Mon, 22 Nov 2010 08:35:25 +0000 (19:35 +1100)
pol_sort could go into an infinite loop.

The proof of this patch is left as a exercise for the reader :-)

Reported-by: "Hawrylewicz Czarnowski, Przemyslaw" <przemyslaw.hawrylewicz.czarnowski@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
policy.c

index 945d37ff6e0007a8d673ad64d824a2709c2f5fb6..5f18034004b59846c9a31ba61ab15b0c4c3730e2 100644 (file)
--- a/policy.c
+++ b/policy.c
@@ -137,8 +137,8 @@ static void pol_sort(struct dev_policy **pol)
                        if (p[next] == NULL ||
                            (p[1-next] != NULL &&
                             !(pol_lesseq(prev, p[1-next])
-                              ^pol_lesseq(p[1-next], p[next])
-                              ^pol_lesseq(p[next], prev)))
+                              ^pol_lesseq(prev, p[next])
+                              ^pol_lesseq(p[next], p[1-next])))
                                )
                                next = 1 - next;