From owner-svn-src-all@freebsd.org Wed Aug 28 04:55:04 2019 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 78D86D151C; Wed, 28 Aug 2019 04:55:04 +0000 (UTC) (envelope-from cy@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 46JD202ZgNz3Fsd; Wed, 28 Aug 2019 04:55:04 +0000 (UTC) (envelope-from cy@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 3A4CB2001; Wed, 28 Aug 2019 04:55:04 +0000 (UTC) (envelope-from cy@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x7S4t4xK019153; Wed, 28 Aug 2019 04:55:04 GMT (envelope-from cy@FreeBSD.org) Received: (from cy@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x7S4t4JC019152; Wed, 28 Aug 2019 04:55:04 GMT (envelope-from cy@FreeBSD.org) Message-Id: <201908280455.x7S4t4JC019152@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: cy set sender to cy@FreeBSD.org using -f From: Cy Schubert Date: Wed, 28 Aug 2019 04:55:04 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r351562 - head/sys/contrib/ipfilter/netinet X-SVN-Group: head X-SVN-Commit-Author: cy X-SVN-Commit-Paths: head/sys/contrib/ipfilter/netinet X-SVN-Commit-Revision: 351562 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 28 Aug 2019 04:55:04 -0000 Author: cy Date: Wed Aug 28 04:55:03 2019 New Revision: 351562 URL: https://svnweb.freebsd.org/changeset/base/351562 Log: Destroy the mutex in case of error. Obtained from: NetBSD ip_nat.c r1.7 MFC after: 3 days Modified: head/sys/contrib/ipfilter/netinet/ip_nat.c Modified: head/sys/contrib/ipfilter/netinet/ip_nat.c ============================================================================== --- head/sys/contrib/ipfilter/netinet/ip_nat.c Wed Aug 28 04:54:26 2019 (r351561) +++ head/sys/contrib/ipfilter/netinet/ip_nat.c Wed Aug 28 04:55:03 2019 (r351562) @@ -3078,7 +3078,7 @@ ipf_nat_newrdr(fin, nat, ni) /* creating a new NAT structure for a "RDR" rule (incoming NAT translation) */ /* and (3) building that structure and putting it into the NAT table(s). */ /* */ -/* NOTE: natsave should NOT be used top point back to an ipstate_t struct */ +/* NOTE: natsave should NOT be used to point back to an ipstate_t struct */ /* as it can result in memory being corrupted. */ /* ------------------------------------------------------------------------ */ nat_t * @@ -3406,6 +3406,7 @@ ipf_nat_insert(softc, softn, nat) u_int hv0, hv1; u_int sp, dp; ipnat_t *in; + int ret; /* * Try and return an error as early as possible, so calculate the hash @@ -3488,7 +3489,10 @@ ipf_nat_insert(softc, softn, nat) nat->nat_mtu[1] = GETIFMTU_4(nat->nat_ifps[1]); } - return ipf_nat_hashtab_add(softc, softn, nat); + ret = ipf_nat_hashtab_add(softc, softn, nat); + if (ret == -1) + MUTEX_DESTROY(&nat->nat_lock); + return ret; }