Received: by 2002:a5b:505:0:0:0:0:0 with SMTP id o5csp7462512ybp; Wed, 16 Oct 2019 09:01:50 -0700 (PDT) X-Google-Smtp-Source: APXvYqw0aCJHi2644LXJy1WbkZbLuh2WGKxybdY685ZQPckUMbuyOYkZVB3mBuBm8GViL8btKE04 X-Received: by 2002:adf:9102:: with SMTP id j2mr3161649wrj.136.1571241710703; Wed, 16 Oct 2019 09:01:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571241710; cv=none; d=google.com; s=arc-20160816; b=rXF4GSamUN7d63xYEp62t7YNrr+OMOjeSexIe50Z68Qa2el9tNff+6hrOfbxwmapBx U7sWvHo63KZ4qudtZkxKtM4jvY8Bx14Jzht2Dd1NUqYSokuvITqqicGBsgRRVvUWAH4L FxKg0+yN8+Z0IYImtiGM/zWjMoELl6UDl84+bK7ZbADyaK0usU4831iiKvMceL/yg281 niwha2uJXd0pIjVYsXoMuqGLInhxyVrQNdkhOOep8+GuTt0X8mFtxA9Kll6d6pa7Tlq9 MePyXIJcQu4yJA+2X4xsEm0mMEfXajAmoVHzRs9EUjgvlPx9IuCIoOVRRAP8o2CSaUgm oPCg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:date:from:dkim-signature; bh=PaygqXHQuaC5ycCiWRMEVFWLxwJSQTfQRD8hMbozOH4=; b=yOk9infyH5NnL3R5Ipvlng52NJUGWwhFD52sqgnKqIWjwQlgVueok7BPHGB5B2c1pP F9FvbjL300epIg7E0TL6neGfNTioomi08tT9ifxgQ9Yx4DRLjvra+AKSw+N0z9OhR/S4 jL0d+Lntk4cY1EarPXt/cxgUGdN5mILFo22HWKZHHRMbLvz5emU814S3M91wdHJe/ETw JmHnvJ5S8UYYNBr/2pRMvFaczv//1N/lAwoF/aJymVjEztezBU2406BLzTog2ckz+nMV moSwMRMlNbStX7LRbIx+/7dJkv677JWZyhIa/H3s8tVRR0/DvMAg3i46k4HCU0INf2XC 0o2g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=a6em5sPq; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b44si18068955ede.451.2019.10.16.09.01.27; Wed, 16 Oct 2019 09:01:50 -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; dkim=pass header.i=@gmail.com header.s=20161025 header.b=a6em5sPq; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2405290AbfJPNEJ (ORCPT + 99 others); Wed, 16 Oct 2019 09:04:09 -0400 Received: from mail-qt1-f194.google.com ([209.85.160.194]:34246 "EHLO mail-qt1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2405282AbfJPNEI (ORCPT ); Wed, 16 Oct 2019 09:04:08 -0400 Received: by mail-qt1-f194.google.com with SMTP id 3so36009220qta.1 for ; Wed, 16 Oct 2019 06:04:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:date:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=PaygqXHQuaC5ycCiWRMEVFWLxwJSQTfQRD8hMbozOH4=; b=a6em5sPq1kYjTh4Gos9mjEHYuHVIoQ98XWy3VObQZGiwnnP/leACZU1CNNpZJ6o60O /mwUxKTvXUlAxlxFSb9BqRu92qGDsiR1JH8G0jOApChowQFE36vSlqfuvz75TUDINh8I Efs05XCBc8g/knvY0gGexx83lnfLwkxJSK91xRB1JUnjpJ2lHjwY+1cYctWgKs0kE8Dv Fs/hA6VbnEZkaHNcqpXZYjpADL+G/oznyiePyh29gY5d8j9jZmwXt4srKXwSTXzAyrAC K3liiotHtoBvrraYMcdDkhVajOafop/kMnFKyS9FQrh4xAum/UiLT+mL1WfF2BO9e1G5 v8bQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:date:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=PaygqXHQuaC5ycCiWRMEVFWLxwJSQTfQRD8hMbozOH4=; b=L04C4PAHhQonVSKQJCD+i7ipFmShgchZODTenZw3hfpIkB1KTCpbR/IPdGEtNh1Kxa bwD5v+QOqcR96VtqM1uOMA5ZYM2j5wKSsBeR3vCnzXlJgg8rqcDpHc+UBLfWzARi9RIX FqQxcy05JHwWbK/KAceExeTjZlQiitQJWci/KdLpbDg6X4RHyustZUb+NiUOVVbI+wSw q9HVu/fww+rioe9n5d6HaC8SVTrmSYMHzDCAo4IrqClwjfgj7WF4WUxzQK5PygqVR+i0 +UhKM7cdYlO7QULg5+RN9a/a1CszSCbf9TmlBomaqEfLeEbxOXgtTIFu6NYSF/p+3rmm wWTQ== X-Gm-Message-State: APjAAAWB9SSJXjn90dYSkNqrmsG5t/sVeF2S5tWUK5hvDsD0A/mFHKip tUIEMRdHpY1Df/XEFs4HYR4= X-Received: by 2002:ac8:368b:: with SMTP id a11mr24854169qtc.362.1571231046562; Wed, 16 Oct 2019 06:04:06 -0700 (PDT) Received: from quaco.ghostprotocols.net ([179.97.35.50]) by smtp.gmail.com with ESMTPSA id b22sm11636807qkc.58.2019.10.16.06.04.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 16 Oct 2019 06:04:05 -0700 (PDT) From: Arnaldo Carvalho de Melo X-Google-Original-From: Arnaldo Carvalho de Melo Received: by quaco.ghostprotocols.net (Postfix, from userid 1000) id BE85B4DD66; Wed, 16 Oct 2019 10:04:03 -0300 (-03) Date: Wed, 16 Oct 2019 10:04:03 -0300 To: Yunfeng Ye Cc: peterz@infradead.org, mingo@redhat.com, mark.rutland@arm.com, alexander.shishkin@linux.intel.com, jolsa@redhat.com, namhyung@kernel.org, linux-kernel@vger.kernel.org, hushiyuan@huawei.com, linfeilong@huawei.com Subject: Re: [PATCH] perf kmem: Fix memory leak in compact_gfp_flags() Message-ID: <20191016130403.GA22835@kernel.org> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Url: http://acmel.wordpress.com User-Agent: Mutt/1.12.1 (2019-06-15) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Em Wed, Oct 16, 2019 at 04:38:45PM +0800, Yunfeng Ye escreveu: > The memory @orig_flags is allocated by strdup(), it is freed on the > normal path, but leak to free on the error path. Are you using some tool to find out these problems? Or is it just visual inspection? - Arnaldo > 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 -- - Arnaldo