Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id CC175C433F5 for ; Wed, 24 Nov 2021 13:56:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346374AbhKXN7N (ORCPT ); Wed, 24 Nov 2021 08:59:13 -0500 Received: from mail.kernel.org ([198.145.29.99]:47000 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1353073AbhKXN4o (ORCPT ); Wed, 24 Nov 2021 08:56:44 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 3C6266124B; Wed, 24 Nov 2021 13:07:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1637759225; bh=C7USxOIkcpRsRrptbiMZyuJXJgY3BvP+jWDsocl3OyE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=M3zC0MTRcIxbWnNebE3ZfQXwSApu6SPSR/ehHojhEcGYyP09UtTf7UBxBaNwTJq+P Mbk2Ud72T/qkW2etI5uVe/6LXj1JD8Re5dBUxNOEX9zroaKp1OLDuP4LP70fyC+OjV cdp4bBqUFg0ssEERHLBOHIPmo5RSlZNma23IZWUM= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Sohaib Mohamed , Ian Rogers , Alexander Shishkin , Hitoshi Mitake , Jiri Olsa , Mark Rutland , Namhyung Kim , Paul Russel , Peter Zijlstra , Pierre Gondois , Arnaldo Carvalho de Melo , Sasha Levin Subject: [PATCH 5.15 173/279] perf bench: Fix two memory leaks detected with ASan Date: Wed, 24 Nov 2021 12:57:40 +0100 Message-Id: <20211124115724.716321669@linuxfoundation.org> X-Mailer: git-send-email 2.34.0 In-Reply-To: <20211124115718.776172708@linuxfoundation.org> References: <20211124115718.776172708@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Sohaib Mohamed [ Upstream commit 92723ea0f11d92496687db8c9725248e9d1e5e1d ] ASan reports memory leaks while running: $ perf bench sched all Fixes: e27454cc6352c422 ("perf bench: Add sched-messaging.c: Benchmark for scheduler and IPC mechanisms based on hackbench") Signed-off-by: Sohaib Mohamed Acked-by: Ian Rogers Cc: Alexander Shishkin Cc: Hitoshi Mitake Cc: Jiri Olsa Cc: Mark Rutland Cc: Namhyung Kim Cc: Paul Russel Cc: Peter Zijlstra Cc: Pierre Gondois Link: http://lore.kernel.org/lkml/20211110022012.16620-1-sohaib.amhmd@gmail.com Signed-off-by: Arnaldo Carvalho de Melo Signed-off-by: Sasha Levin --- tools/perf/bench/sched-messaging.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tools/perf/bench/sched-messaging.c b/tools/perf/bench/sched-messaging.c index 488f6e6ba1a55..fa0ff4ce2b749 100644 --- a/tools/perf/bench/sched-messaging.c +++ b/tools/perf/bench/sched-messaging.c @@ -223,6 +223,8 @@ static unsigned int group(pthread_t *pth, snd_ctx->out_fds[i] = fds[1]; if (!thread_mode) close(fds[0]); + + free(ctx); } /* Now we have all the fds, fork the senders */ @@ -239,6 +241,8 @@ static unsigned int group(pthread_t *pth, for (i = 0; i < num_fds; i++) close(snd_ctx->out_fds[i]); + free(snd_ctx); + /* Return number of children to reap */ return num_fds * 2; } -- 2.33.0