Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757953AbcCUXAX (ORCPT ); Mon, 21 Mar 2016 19:00:23 -0400 Received: from youngberry.canonical.com ([91.189.89.112]:48763 "EHLO youngberry.canonical.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756426AbcCUXAU (ORCPT ); Mon, 21 Mar 2016 19:00:20 -0400 From: Colin King To: Paul Moore , Stephen Smalley , Eric Paris , James Morris , "Serge E . Hallyn" , Nick Kralevich , Jeff Vander Stoep , selinux@tycho.nsa.gov, linux-security-module@vger.kernel.org Cc: linux-kernel@vger.kernel.org Subject: [PATCH] selinux: fix memory leak on node_ptr on error return path Date: Mon, 21 Mar 2016 23:00:13 +0000 Message-Id: <1458601213-5835-1-git-send-email-colin.king@canonical.com> X-Mailer: git-send-email 2.7.3 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 737 Lines: 24 From: Colin Ian King node_ptr is not being free'd if the list allocation fails, fix this by kfree'ing it before exiting on the error path. Signed-off-by: Colin Ian King --- security/selinux/ss/conditional.c | 1 + 1 file changed, 1 insertion(+) diff --git a/security/selinux/ss/conditional.c b/security/selinux/ss/conditional.c index 456e1a9..5d010ef 100644 --- a/security/selinux/ss/conditional.c +++ b/security/selinux/ss/conditional.c @@ -332,6 +332,7 @@ static int cond_insertf(struct avtab *a, struct avtab_key *k, struct avtab_datum list = kzalloc(sizeof(struct cond_av_list), GFP_KERNEL); if (!list) { rc = -ENOMEM; + kfree(node_ptr); goto err; } -- 2.7.3