Date: Wed, 24 Jan 2018 16:13:10 -0800 From: Gleb Smirnoff <glebius@FreeBSD.org> To: Kristof Provost <kp@FreeBSD.org> Cc: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: Re: svn commit: r328313 - head/sys/netpfil/pf Message-ID: <20180125001310.GJ8113@FreeBSD.org> In-Reply-To: <201801240429.w0O4THIl059440@repo.freebsd.org> References: <201801240429.w0O4THIl059440@repo.freebsd.org>
next in thread | previous in thread | raw e-mail | index | archive | help
Hi Kristof, On Wed, Jan 24, 2018 at 04:29:17AM +0000, Kristof Provost wrote: K> Author: kp K> Date: Wed Jan 24 04:29:16 2018 K> New Revision: 328313 K> URL: https://svnweb.freebsd.org/changeset/base/328313 K> K> Log: K> pf: States have at least two references K> K> pf_unlink_state() releases a reference to the state without checking if K> this is the last reference. It can't be, because pf_state_insert() K> initialises it to two. KASSERT() that this is always the case. K> K> CID: 1347140 K> K> Modified: K> head/sys/netpfil/pf/pf.c K> K> Modified: head/sys/netpfil/pf/pf.c K> ============================================================================== K> --- head/sys/netpfil/pf/pf.c Wed Jan 24 03:09:56 2018 (r328312) K> +++ head/sys/netpfil/pf/pf.c Wed Jan 24 04:29:16 2018 (r328313) K> @@ -1613,6 +1613,7 @@ int K> pf_unlink_state(struct pf_state *s, u_int flags) K> { K> struct pf_idhash *ih = &V_pf_idhash[PF_IDHASH(s)]; K> + int last; K> K> if ((flags & PF_ENTER_LOCKED) == 0) K> PF_HASHROW_LOCK(ih); K> @@ -1653,7 +1654,8 @@ pf_unlink_state(struct pf_state *s, u_int flags) K> PF_HASHROW_UNLOCK(ih); K> K> pf_detach_state(s); K> - refcount_release(&s->refs); K> + last = refcount_release(&s->refs); K> + KASSERT(last == 0, ("Incorrect state reference count")); K> K> return (pf_release_state(s)); K> } IMHO, we shouldn't emit extra code to please Coverity. We can mark it as a false positive in the interface. It may make sense to add a comment for a human to explain why return isn't checked here. -- Gleb Smirnoff
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20180125001310.GJ8113>