Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 19 Mar 2018 21:13:25 +0000 (UTC)
From:      Kristof Provost <kp@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r331225 - head/sys/netpfil/pf
Message-ID:  <201803192113.w2JLDP85033955@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: kp
Date: Mon Mar 19 21:13:25 2018
New Revision: 331225
URL: https://svnweb.freebsd.org/changeset/base/331225

Log:
  pf: Fix memory leak in DIOCRADDTABLES
  
  If a user attempts to add two tables with the same name the duplicate table
  will not be added, but we forgot to free the duplicate table, leaking memory.
  Ensure we free the duplicate table in the error path.
  
  Reported by:	Coverity
  CID:		1382111
  MFC after:	3 weeks

Modified:
  head/sys/netpfil/pf/pf_table.c

Modified: head/sys/netpfil/pf/pf_table.c
==============================================================================
--- head/sys/netpfil/pf/pf_table.c	Mon Mar 19 20:55:05 2018	(r331224)
+++ head/sys/netpfil/pf/pf_table.c	Mon Mar 19 21:13:25 2018	(r331225)
@@ -1131,8 +1131,10 @@ pfr_add_tables(struct pfr_table *tbl, int size, int *n
 			if (p == NULL)
 				senderr(ENOMEM);
 			SLIST_FOREACH(q, &addq, pfrkt_workq) {
-				if (!pfr_ktable_compare(p, q))
+				if (!pfr_ktable_compare(p, q)) {
+					pfr_destroy_ktable(p, 0);
 					goto _skip;
+				}
 			}
 			SLIST_INSERT_HEAD(&addq, p, pfrkt_workq);
 			xadd++;



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201803192113.w2JLDP85033955>