Received: by 2002:a5b:505:0:0:0:0:0 with SMTP id o5csp7238757ybp; Wed, 16 Oct 2019 05:59:43 -0700 (PDT) X-Google-Smtp-Source: APXvYqxsoYDEG+tVD4sJ9GQH0+5ALfx8zs4JNlLozmjJycU6Ycaxun6NLKYiBZ8vlo7hLHIUWnKo X-Received: by 2002:a17:906:4948:: with SMTP id f8mr38942188ejt.318.1571230783468; Wed, 16 Oct 2019 05:59:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571230783; cv=none; d=google.com; s=arc-20160816; b=po6F6Dp31x1TjWhiBYsLIYHwduYcVg5/mcCJtR7v1IOb+mJVARwkQ94OT6JNerLsK3 hoxu0jOorm+1sRxJk4duT2DQURqn0rQNR6NIYhu071u+LD89kfaGo4taDgOFOZN9/gra mSOkaiXJ5jrwBCTePTXKiQ/BSJckgJQtTfQQWF0TSyyUcmhN/GQ4lne7EW7jV04A3yjG oCrDw3OZpbJxnvmJV98vCeMm5gYIu1491+9rkLLILQIuuGdRe5X2nlpy0bmSGPlPWIdi oTaDG1aRUJgPgQTWpbgkaoIE3Lm4S0Y1S4CoJU3YTGU5T07swfK855JiPfY7CvSXgGCi o3zw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:mime-version:user-agent:date:message-id:subject :from:cc:to; bh=xfek2F4XszTzx7Wsva4qyk6sPgJi5jvl5PIgEw/8A1I=; b=ixsmbIl2BBvFpOqsjq+aiKkrraFgt6wBjAIobgkKHgR6oYz4aR9I3JcQ0MGTUhTZ9U dGNIOHprD7QRiZbF5HMjOB7st0HWma6uUGsLjdr7qQNyJCNbpQA10jXpoqPzsrKGDdAV 5kR826z3jkCSQqTjOTjS1bY0CzWnx1nECrg90J70R6rht49dhwSmaT6LlXFnYtDvR0Be mT7mSHbe1zt4GiBxpkw9ZEfY1L2+hU4cV3QZ8310MSNJcTPthUXdlydTclhkCkUk75iy U5iGgigYc/QKBpGWi1xx65/v7UP4qwc04h1GomsJ/qq1ENeyqCEB3ablKxliHPdVaszK iiHg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w54si18599129edd.427.2019.10.16.05.59.20; Wed, 16 Oct 2019 05:59:43 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2390166AbfJPIjL (ORCPT + 99 others); Wed, 16 Oct 2019 04:39:11 -0400 Received: from szxga04-in.huawei.com ([45.249.212.190]:4179 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726231AbfJPIjL (ORCPT ); Wed, 16 Oct 2019 04:39:11 -0400 Received: from DGGEMS410-HUB.china.huawei.com (unknown [172.30.72.58]) by Forcepoint Email with ESMTP id 8E7ABE0BD387906DB3AB; Wed, 16 Oct 2019 16:39:07 +0800 (CST) Received: from [127.0.0.1] (10.177.251.225) by DGGEMS410-HUB.china.huawei.com (10.3.19.210) with Microsoft SMTP Server id 14.3.439.0; Wed, 16 Oct 2019 16:38:57 +0800 To: , , , , , , CC: , , From: Yunfeng Ye Subject: [PATCH] perf kmem: Fix memory leak in compact_gfp_flags() Message-ID: Date: Wed, 16 Oct 2019 16:38:45 +0800 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.6.1 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Language: en-US Content-Transfer-Encoding: 7bit X-Originating-IP: [10.177.251.225] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. Signed-off-by: Yunfeng Ye --- 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 1e61e353f579..9661671cc26e 100644 --- a/tools/perf/builtin-kmem.c +++ b/tools/perf/builtin-kmem.c @@ -691,6 +691,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.7.4.3