--- x/net/xfrm/xfrm_state.c +++ y/net/xfrm/xfrm_state.c @@ -798,6 +798,7 @@ void xfrm_dev_state_free(struct xfrm_sta void __xfrm_state_destroy(struct xfrm_state *x) { WARN_ON(x->km.state != XFRM_STATE_DEAD); + WARN_ON(!hlist_unhashed(&x->bydst)); spin_lock_bh(&xfrm_state_gc_lock); hlist_add_head(&x->gclist, &xfrm_state_gc_list); @@ -934,14 +935,15 @@ restart: if (!xfrm_state_kern(x) && xfrm_id_proto_match(x->id.proto, proto)) { xfrm_state_hold(x); + if (x->km.state == XFRM_STATE_DEAD) + x->km.state++; spin_unlock_bh(&net->xfrm.xfrm_state_lock); err = xfrm_state_delete(x); xfrm_audit_state_delete(x, err ? 0 : 1, task_valid); xfrm_state_put(x); - if (!err) - cnt++; + cnt++; spin_lock_bh(&net->xfrm.xfrm_state_lock); goto restart;