From a5bdb72d2e0d937ba66ab6dd7e0700cc9ec618d0 Mon Sep 17 00:00:00 2001 From: Herbert Xu Date: Wed, 20 Oct 2004 07:49:52 -0700 Subject: [PATCH] [XFRM]: Fix policy update bug when increasing priority of last policy. Based upon a patch by Patrick McHardy. Signed-off-by: Herbert Xu Signed-off-by: David S. Miller --- net/xfrm/xfrm_policy.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/net/xfrm/xfrm_policy.c b/net/xfrm/xfrm_policy.c index 63723042d813b..1708bf045a2bb 100644 --- a/net/xfrm/xfrm_policy.c +++ b/net/xfrm/xfrm_policy.c @@ -332,7 +332,7 @@ int xfrm_policy_insert(int dir, struct xfrm_policy *policy, int excl) struct xfrm_policy **newpos = NULL; write_lock_bh(&xfrm_policy_lock); - for (p = &xfrm_policy_list[dir]; (pol=*p)!=NULL; p = &pol->next) { + for (p = &xfrm_policy_list[dir]; (pol=*p)!=NULL;) { if (!delpol && memcmp(&policy->selector, &pol->selector, sizeof(pol->selector)) == 0) { if (excl) { write_unlock_bh(&xfrm_policy_lock); @@ -342,8 +342,10 @@ int xfrm_policy_insert(int dir, struct xfrm_policy *policy, int excl) delpol = pol; if (policy->priority > pol->priority) continue; - } else if (policy->priority >= pol->priority) + } else if (policy->priority >= pol->priority) { + p = &pol->next; continue; + } if (!newpos) newpos = p; if (delpol) -- 2.53.0