From: NeilBrown Date: Mon, 22 Nov 2010 08:35:25 +0000 (+1100) Subject: Fix error in pol_sort. X-Git-Tag: mdadm-3.2~318 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=37194990aae3dfdbaae55fb9d2ab491683ade7e1;p=thirdparty%2Fmdadm.git Fix error in pol_sort. 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" Signed-off-by: NeilBrown --- diff --git a/policy.c b/policy.c index 945d37ff..5f180340 100644 --- 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;