linux-security-module.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] genetlink: prevent memory leak in netlbl_unlabel_defconf
@ 2019-09-25 22:10 Navid Emamdoost
  2019-09-25 23:27 ` Paul Moore
  0 siblings, 1 reply; 5+ messages in thread
From: Navid Emamdoost @ 2019-09-25 22:10 UTC (permalink / raw)
  Cc: emamd001, kjlu, smccaman, Navid Emamdoost, Paul Moore,
	David S. Miller, netdev, linux-security-module, linux-kernel

In netlbl_unlabel_defconf if netlbl_domhsh_add_default fails the
allocated entry should be released.

Signed-off-by: Navid Emamdoost <navid.emamdoost@gmail.com>
---
 net/netlabel/netlabel_unlabeled.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/net/netlabel/netlabel_unlabeled.c b/net/netlabel/netlabel_unlabeled.c
index d2e4ab8d1cb1..c63ec480ee4e 100644
--- a/net/netlabel/netlabel_unlabeled.c
+++ b/net/netlabel/netlabel_unlabeled.c
@@ -1541,8 +1541,10 @@ int __init netlbl_unlabel_defconf(void)
 	entry->family = AF_UNSPEC;
 	entry->def.type = NETLBL_NLTYPE_UNLABELED;
 	ret_val = netlbl_domhsh_add_default(entry, &audit_info);
-	if (ret_val != 0)
+	if (ret_val != 0) {
+		kfree(entry);
 		return ret_val;
+	}
 
 	netlbl_unlabel_acceptflg_set(1, &audit_info);
 
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2019-09-27 16:14 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-09-25 22:10 [PATCH] genetlink: prevent memory leak in netlbl_unlabel_defconf Navid Emamdoost
2019-09-25 23:27 ` Paul Moore
2019-09-27 13:15   ` Markus Elfring
2019-09-27 14:48     ` Paul Moore
2019-09-27 16:14       ` David Miller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).