===== net/xfrm/xfrm_state.c 1.39 vs edited ===== --- 1.39/net/xfrm/xfrm_state.c 2004-05-22 17:32:10 +10:00 +++ edited/net/xfrm/xfrm_state.c 2004-05-25 21:42:43 +10:00 @@ -331,14 +331,8 @@ } } - if (best) { - xfrm_state_hold(best); - spin_unlock_bh(&xfrm_state_lock); - return best; - } - - x = NULL; - if (!error && !acquire_in_progress && + x = best; + if (!x && !error && !acquire_in_progress && ((x = xfrm_state_alloc()) != NULL)) { /* Initialize temporary selector matching only * to current session. */ @@ -363,10 +357,12 @@ error = 1; } } - spin_unlock_bh(&xfrm_state_lock); - if (!x) + if (x) + xfrm_state_hold(x); + else *err = acquire_in_progress ? -EAGAIN : (error ? -ESRCH : -ENOMEM); + spin_unlock_bh(&xfrm_state_lock); return x; }