Received: by 2002:ab2:7a09:0:b0:1f8:46dc:890e with SMTP id k9csp275945lqo; Wed, 15 May 2024 14:14:41 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUSwqVmCMB3KrkBwxei4mF1PiOIQvviT77WXQMCGj2ZPvc2jtg9FyIxxNGkL1fONbHIPsSxMpGdfBmNaKSAHlFYIigdvjXily8C0U1NBg== X-Google-Smtp-Source: AGHT+IFfQe4b/Rha6ozjqeGq9MQlsN/MpfKyax5taFi8B1fy+WSyIl324UbO04YLpbqAb2l0SjAl X-Received: by 2002:a05:620a:2847:b0:790:c18f:5d94 with SMTP id af79cd13be357-792bbdc5457mr3398159685a.4.1715807680726; Wed, 15 May 2024 14:14:40 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715807680; cv=pass; d=google.com; s=arc-20160816; b=NOO5ADRM75xORtsqCtrYKtuifXIO+/9pJBKFjkNQta1S61DVe3+Y2+e5ohM3DQ6dYC wrn2b9KKXsZjT+92H3pCwCY8XoDF2c1WHqH9QhdH4AD+SgU40NenfUcb7XipKCR5tDv2 lfRcJi6bYZgPw1zjad5m/jrlWOlYrSLkWI1P4i3R9o5jNXSycGoVdNquMrVKo8WUHZtE Qdk9doOEAjZDhkUge6th/HQqcvJnWg2AX8zcAUwrTqPsgwdrjjxksAG7MAYAFTQNddPy ehG9OdQkvjPwrnZlMB4pYtzjYr87S6og4nuqCmPzsprjrlKa2+ZAqUVWB6T8TRjT8ueU +4Ag== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:dkim-signature; bh=ASfis+VjxPRoonpfr9uzosJOMgG1sBNuU5vYcng9bn8=; fh=iUiUcmz2SXhfNkpeSxNwvKXrf9xwc8oM1n5vqfA2rmI=; b=HGqg5vtwywY1mTHFKI+dpyvyTauy/SSi6xQ7V0rLH3zRTD8SbMNR3SerG13Zyan8Jr i0KAsb3cCbaqvu5FKsx/tGQrmhO4EuDwsoALo2kc7dzS279+XP5jMbLX+kwmkRsIx5pq 1dOoWXy2olvWRMcxIYDOmLBXiQwE27OSrM61Wp2IDDVomzE/oifs+nyfsFAaoPtWC3/X tbBw9FPNzFX1RxWKWMGrfxBG5etkN5dSXo59lrjLy7JBMJ9Z5/sX8VvPD+EyhC00ZBAW KpLl4Z4VBwJEjXPBELc7p+nTVi4tglJGFOQoq8GDOCjo+iaXSvQVUPPG4jSelFXd8VtE 552A==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=yzckX8xk; arc=pass (i=1 spf=pass spfdomain=google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-180373-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-180373-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id af79cd13be357-792bf297cbdsi1525372685a.199.2024.05.15.14.14.40 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 May 2024 14:14:40 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-180373-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=yzckX8xk; arc=pass (i=1 spf=pass spfdomain=google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-180373-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-180373-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 74A7B1C2228F for ; Wed, 15 May 2024 21:14:40 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 4D61515B14D; Wed, 15 May 2024 21:14:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="yzckX8xk" Received: from mail-il1-f181.google.com (mail-il1-f181.google.com [209.85.166.181]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 469C915B544 for ; Wed, 15 May 2024 21:14:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.166.181 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715807672; cv=none; b=kwALLSukS5Zg/01r3ntq8PkmfjnlsfAy+zaalmu3uA/A4Q24aVT45a/mqLCKtVFH0xAKmc8Y6kTaXMUxxxclIdJ6tbTRc58gCipLaXRCC2nAgEFrnzWU6dNAfa+Bmjuy1Zy6UZ9jlyiEzxMzoSsDGx+VinJMnsyhC+dIOqBCWSM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715807672; c=relaxed/simple; bh=KaRp03zPMicROwGMtQ24BK5CzqpLG2F6m7G378tiArU=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=BJVYZl0BVbM6gLFTTs13qAhdldcm+QIzUl1lwGa3dvvlrgp6aYxtx59b191VoUDz2YUEJM+Bv3HLpejTxC7+9IupCfq9hK6hvyHcfnYcr5Yx+W+Qkb1PmRnzD92EXozgDMS3O526jO/KlmugeProTf7rUyygN1k1oELezf53UHs= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=yzckX8xk; arc=none smtp.client-ip=209.85.166.181 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=google.com Received: by mail-il1-f181.google.com with SMTP id e9e14a558f8ab-36db863679bso91425ab.1 for ; Wed, 15 May 2024 14:14:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1715807669; x=1716412469; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=ASfis+VjxPRoonpfr9uzosJOMgG1sBNuU5vYcng9bn8=; b=yzckX8xkL8Zki6q6lA03WU1eTmHEcdNNp9EJzOxq0ruAVkfW1KBaSLL0s4eP+3bMoH 69qzgHkqqb6OJt+mpYFQmZLzvpvi8x9cg3veE2XEs+Mw54/09xMh1mvU8lXvitD0b89S MEkm/Culk27XWANSOYK7MC0cVyoC1TRBCMySoemH5hM0zaVNiPuwrVOaYo9hesajWBFJ Gd8moZKuFhjPVec4EDRlPHGXP2CMAomyVVVShR6eIKRo2HBbb7pm9n1z732PwfY5clvh DCvs0RK01hH/PykPj1VVHPRaSVXKm/4BLVsiB3cFjgQ2mJSCxJU5yWH78zuwkmYLOw/p 0+Qg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715807669; x=1716412469; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ASfis+VjxPRoonpfr9uzosJOMgG1sBNuU5vYcng9bn8=; b=rZ7Sj1b3HndGXwYnqi4nvMfi64EG3nTAiOaUAsiX9YXp+fcGwRh0UMfOJFyS1QJilR do8buBIGGfWmNSoLW0m+GS9Pg5OB78UL6JPn3KNA5qjdSY4m5OS+YeBowByTWVApl0yj yt1O1TZCFz+mYzvbumfe52ZtYf8fF+PuxG6o1dv55zhpLMMP54jZ5HY9O0sMksYzfilg agXfdW9ITRB5IU+9Shy+8g3bbPxC+8VJYDhIuJhuUJR2WlB9cAX4HlZVCnOvg9qAwr8K Wn7NRBX/sdqgm7diuSqOy6tecZTygPCZmqgGXeFK/WDXqjNHCNsz0F35Rn1c2UNIAOwH 4Eow== X-Forwarded-Encrypted: i=1; AJvYcCXDvvyohX+fI7aer9Ah9FPL6K7mfaS/e1DFPiKY7cUz3NgdOcDDoLBJjZBh7wfX5j3Towcq+VP52mCYFPfsRLyLk7a93vkibGscyEBQ X-Gm-Message-State: AOJu0YzQRJNjbdosgd7XxW7160FTtvWrxUTJ1Zj0BxO/vmcCAZs5LYwF 3/BrgDKTdVBpC4aSZ+OIBJetCDMnwQUbYAMcWESeNCdOMpt1nk+8wApimPCKP+kowwNszNSoqJa 1TGDtFBeipxt9RBfXqgDF5Kf9S5cbIf3jE+Dc X-Received: by 2002:a92:de03:0:b0:36d:b340:330 with SMTP id e9e14a558f8ab-36db3400540mr4953095ab.26.1715807668933; Wed, 15 May 2024 14:14:28 -0700 (PDT) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240515182750.489472-1-samasth.norway.ananda@oracle.com> In-Reply-To: <20240515182750.489472-1-samasth.norway.ananda@oracle.com> From: Ian Rogers Date: Wed, 15 May 2024 14:14:15 -0700 Message-ID: Subject: Re: [PATCH RESEND] perf test pmu: Fix file Leak in test_format_dir_get To: Samasth Norway Ananda Cc: namhyung@kernel.org, acme@kernel.org, peterz@infradead.org, mingo@redhat.com, mark.rutland@arm.com, alexander.shishkin@linux.intel.com, jolsa@kernel.org, adrian.hunter@intel.com, linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Wed, May 15, 2024 at 11:27=E2=80=AFAM Samasth Norway Ananda wrote: > > File is opened inside the for loop. But if the 'if' condition is > successful then 'break' statement will be reached, exiting the > 'for' loop prior to reaching 'fclose'. > > Signed-off-by: Samasth Norway Ananda > --- > Found this error through static analysis. This has only been compile > tested. Thanks Samasth, I agree with the fix however this code was recently deleted and isn't in our next tree: https://git.kernel.org/pub/scm/linux/kernel/git/perf/perf-tools-next.git/tr= ee/tools/perf/tests/pmu.c?h=3Dperf-tools-next the change that removed the code is: https://lore.kernel.org/all/20240502213507.2339733-4-irogers@google.com/ Thanks, Ian > --- > tools/perf/tests/pmu.c | 4 +++- > 1 file changed, 3 insertions(+), 1 deletion(-) > > diff --git a/tools/perf/tests/pmu.c b/tools/perf/tests/pmu.c > index 8f18127d876a..f751e6cb6ac0 100644 > --- a/tools/perf/tests/pmu.c > +++ b/tools/perf/tests/pmu.c > @@ -106,8 +106,10 @@ static char *test_format_dir_get(char *dir, size_t s= z) > if (!file) > return NULL; > > - if (1 !=3D fwrite(format->value, strlen(format->value), 1= , file)) > + if (1 !=3D fwrite(format->value, strlen(format->value), 1= , file)) { > + fclose(file); > break; > + } > > fclose(file); > } > -- > 2.43.0 >