From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932293AbdDPIGR (ORCPT ); Sun, 16 Apr 2017 04:06:17 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:57014 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932266AbdDPIGK (ORCPT ); Sun, 16 Apr 2017 04:06:10 -0400 From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Colin Ian King , Mike Marshall , Martin Brandenburg Subject: [PATCH 4.9 08/31] orangefs: fix memory leak of string new on exit path Date: Sun, 16 Apr 2017 10:03:59 +0200 Message-Id: <20170416080222.235079692@linuxfoundation.org> X-Mailer: git-send-email 2.12.2 In-Reply-To: <20170416080221.808058771@linuxfoundation.org> References: <20170416080221.808058771@linuxfoundation.org> User-Agent: quilt/0.65 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.9-stable review patch. If anyone has any objections, please let me know. ------------------ From: Colin Ian King commit 4defb5f912a0ba60e07e91a4b62634814cd99b7f upstream. allocates string 'new' is not free'd on the exit path when cdm_element_count <= 0. Fix this by kfree'ing it. Fixes CoverityScan CID#1375923 "Resource Leak" Signed-off-by: Colin Ian King Signed-off-by: Mike Marshall Signed-off-by: Martin Brandenburg Signed-off-by: Greg Kroah-Hartman --- fs/orangefs/orangefs-debugfs.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) --- a/fs/orangefs/orangefs-debugfs.c +++ b/fs/orangefs/orangefs-debugfs.c @@ -671,8 +671,10 @@ int orangefs_prepare_debugfs_help_string */ cdm_element_count = orangefs_prepare_cdm_array(client_debug_array_string); - if (cdm_element_count <= 0) + if (cdm_element_count <= 0) { + kfree(new); goto out; + } for (i = 0; i < cdm_element_count; i++) { strlcat(new, "\t", string_size);