From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7E7D6FA372C for ; Fri, 8 Nov 2019 19:06:39 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 49902215EA for ; Fri, 8 Nov 2019 19:06:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1573239999; bh=GmX8cLHHCLcH0jyirZhUVzUZAqPDhHoRUAz/dz5YXOc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=c9qNskNcz5bq8FVFR0+fev715RdHsJVY8yTHiXAn0yMq2slAmAq5G+mxi45QP7gJ+ 0ITxLntcqfgNmyOvjiORCtZxSKXw7gn40dX07OoEOq3o+mbG8Lflj2mPOBbYbDXLeI hJRjnjWSAzXs7vBTvkah9h83Xfl2bqgnGgtUeJqc= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389816AbfKHTGi (ORCPT ); Fri, 8 Nov 2019 14:06:38 -0500 Received: from mail.kernel.org ([198.145.29.99]:37076 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2391291AbfKHTGf (ORCPT ); Fri, 8 Nov 2019 14:06:35 -0500 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 8B89221D7F; Fri, 8 Nov 2019 19:06:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1573239994; bh=GmX8cLHHCLcH0jyirZhUVzUZAqPDhHoRUAz/dz5YXOc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=gtUcZ14aLs+7n9cKrYI8vlBRcWbwAvcuR+A+9aMkBR5b3Vtlwtt74+5fxM3ne64EC M1BG/39MjHHlvtDQDs7PdIyJeiGMwgK0rZ5rV7obAMsuAlUGyBo+yy3GQOns5nKe6Z 8GSNiW5DJUXIeWZNAfuFxfyqmQsMq5TqlER6XTGM= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Yunfeng Ye , Alexander Shishkin , Feilong Lin , Hu Shiyuan , Jiri Olsa , Mark Rutland , Namhyung Kim , Peter Zijlstra , Arnaldo Carvalho de Melo , Sasha Levin Subject: [PATCH 5.3 052/140] perf kmem: Fix memory leak in compact_gfp_flags() Date: Fri, 8 Nov 2019 19:49:40 +0100 Message-Id: <20191108174908.634303734@linuxfoundation.org> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20191108174900.189064908@linuxfoundation.org> References: <20191108174900.189064908@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Yunfeng Ye [ Upstream commit 1abecfcaa7bba21c9985e0136fa49836164dd8fd ] The memory @orig_flags is allocated by strdup(), it is freed on the normal path, but leak to free on the error path. Fix this by adding free(orig_flags) on the error path. Fixes: 0e11115644b3 ("perf kmem: Print gfp flags in human readable string") Signed-off-by: Yunfeng Ye Cc: Alexander Shishkin Cc: Feilong Lin Cc: Hu Shiyuan Cc: Jiri Olsa Cc: Mark Rutland Cc: Namhyung Kim Cc: Peter Zijlstra Link: http://lore.kernel.org/lkml/f9e9f458-96f3-4a97-a1d5-9feec2420e07@huawei.com Signed-off-by: Arnaldo Carvalho de Melo Signed-off-by: Sasha Levin --- tools/perf/builtin-kmem.c | 1 + 1 file changed, 1 insertion(+) diff --git a/tools/perf/builtin-kmem.c b/tools/perf/builtin-kmem.c index 9e5e608980832..353c9417e864b 100644 --- a/tools/perf/builtin-kmem.c +++ b/tools/perf/builtin-kmem.c @@ -688,6 +688,7 @@ static char *compact_gfp_flags(char *gfp_flags) new = realloc(new_flags, len + strlen(cpt) + 2); if (new == NULL) { free(new_flags); + free(orig_flags); return NULL; } -- 2.20.1