Received: by 2002:ab2:b82:0:b0:1f3:401:3cfb with SMTP id 2csp1079137lqh; Fri, 29 Mar 2024 06:45:55 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXsBR7McvM2IhxxJG5EgYUE4aBji4N8z4XcZGRplIPSfilpqz0cBPS3MDhaWbtCKkz6ojt/N2uL2j+az1qG2DMQ0ad+54SpzblX1Sh1fg== X-Google-Smtp-Source: AGHT+IFbsi1tc85cD88fMtznQcDtAGx/HgSnyBwiUotePS7jEDc78OLS7sSHngcR7k3G4Mlh0PX/ X-Received: by 2002:a19:c51a:0:b0:513:e7cc:97fc with SMTP id w26-20020a19c51a000000b00513e7cc97fcmr2006828lfe.49.1711719955739; Fri, 29 Mar 2024 06:45:55 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711719955; cv=pass; d=google.com; s=arc-20160816; b=JH1RxIDZZZ4hvp3hq7uPJ6WgujqRBE9LGFlSwUu0gDI166Of2XZ2EL1w7Z3R++Uxct pDjyvY9XCqPuqA+0ihmoyZMOPDPc/kNtsuna5doViCdttsxmMIgHGyJoOH1ImIOt2u+g SGFUFW/rT1ONGkP4Y5Q3vlR92t4zpdP4Inyy4WUrLlvsd9t2Flg5c6D0o2gAjURoYjKZ wZ3x7r5i70DTccGxYBmo+JfjyYOeXtK5r4Fs3mdsr5j+mJwHFXP9qgsSBu5wIESj5V5N +wDmcBAnnIQT23/PJiMXqd4iGWkOY0FFBQC5CKNptSz8A0EUTYeZetonQw7LX77rI+wS OV2Q== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=MQ9Vi99RUg0NtX5bEhT8SIJZTjSEKYvV89R4x/xOpK8=; fh=uACmh9CBboVAyA0k/n4E4N2wQlAPuZl2uMFAw7P3a8Q=; b=T3bT6etNl1xexDAga7uw2ejCoY3ByL5eTUhOBKe7NKCwmL78CeOlOod1/S+uA/aGsZ gNEv1t8U6N7XSHdSvZ5+nnfCgush2nb1IWEHhBf3vWAsjwX6RI+ZkwHOJKSNgi3e8a4r +TRx836yf+UFcP6iLhB9xuvG4bhCHGuZ8WPOEZET1qufPBMbniYN99FOHTU3PoB4pIUV F6B1lA1aqp8uxWzXVnm9i2wt18rLdKRXKcYA47FcRuT1zcTEC+rgne4FwWVpH4Czm94H O7e8M0yYKT2yxGZVWe883dR2/eKAUJoGpBaZbsZ9chBDSdUM7evU2UsYhnhJ1T5rsGTg RrtQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="Oo3zD6/A"; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-124765-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-124765-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id t3-20020a170906178300b00a4761adde1bsi1813446eje.607.2024.03.29.06.45.55 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 Mar 2024 06:45:55 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-124765-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="Oo3zD6/A"; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-124765-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-124765-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org 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 am.mirrors.kernel.org (Postfix) with ESMTPS id 7468E1F231D0 for ; Fri, 29 Mar 2024 13:45:55 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id AE33E181494; Fri, 29 Mar 2024 12:41:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Oo3zD6/A" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BD31718146D; Fri, 29 Mar 2024 12:41:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711716104; cv=none; b=k6f4IVo79SAl30FJywv2ArHYYxgWqb0GuMcNRqEl47LKubBWuK6pyWk/TK8servEIvPQSKiiOptiBY7b3EPJpodsyoqkWcUVMFUKwwFk5xgGPDn+uma+W2YgQGzMTtbIzBeJXcUe59ktEsRteTOQ7QW4fQSEliMVtLxb3eHvLgo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711716104; c=relaxed/simple; bh=Kdyszlwq5JIK92eTlec4mtX/vVJlwIS0I5GaYJWP4a0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=a5E3saSDW6vp8oXno4ONohqMeTcRFcbJJnCB0AuGFD96B87k3249jXMQnisiYhBS043UfRXCqgZLVsiEbI7Jg6FiEPOWV5sEJE/a5Xk2J651GEF0QLy43QlQ+TUto+BVE8ENF5RHJMurDFIwgrx0rIwlTxbQGyW4t+LpjCTnsOE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Oo3zD6/A; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0D299C43390; Fri, 29 Mar 2024 12:41:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1711716104; bh=Kdyszlwq5JIK92eTlec4mtX/vVJlwIS0I5GaYJWP4a0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Oo3zD6/AEdSYxrlsBHpgRDceozMlGLQtcRC1qM5MG3zupbgsbpTh8pNVP2YexAv3g uKTUogzk/LI4jtOmthdaSk8Y3EpfkDn6aQEc16TfDDFvcQ0KB50Lw6mfMThgnWvDD6 XqCBYbGs6XoPrGpc86SW504K0wt+432byGoucf0k8Ej+h80dXsIWMvAE4fzPrz3eZ5 CS81X5BaDtPr6EMcF/KKAVUfY4ttQNIYfLzm1RxDKlurpR9SLO9BzEg+euE2apGIP8 mnlKH07jqboFtRwm5IfWYMjmXxBfC+JfismmTCCCNc41RtP9dLDzyiLGcSzUL6O7OA Vcv/4yx3ghMjQ== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Samasth Norway Ananda , "Rafael J . Wysocki" , Sasha Levin Subject: [PATCH AUTOSEL 6.8 56/98] tools/power x86_energy_perf_policy: Fix file leak in get_pkg_num() Date: Fri, 29 Mar 2024 08:37:27 -0400 Message-ID: <20240329123919.3087149-56-sashal@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240329123919.3087149-1-sashal@kernel.org> References: <20240329123919.3087149-1-sashal@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore X-stable-base: Linux 6.8.2 Content-Transfer-Encoding: 8bit From: Samasth Norway Ananda [ Upstream commit f85450f134f0b4ca7e042dc3dc89155656a2299d ] In function get_pkg_num() if fopen_or_die() succeeds it returns a file pointer to be used. But fclose() is never called before returning from the function. Signed-off-by: Samasth Norway Ananda Signed-off-by: Rafael J. Wysocki Signed-off-by: Sasha Levin --- tools/power/x86/x86_energy_perf_policy/x86_energy_perf_policy.c | 1 + 1 file changed, 1 insertion(+) diff --git a/tools/power/x86/x86_energy_perf_policy/x86_energy_perf_policy.c b/tools/power/x86/x86_energy_perf_policy/x86_energy_perf_policy.c index 5fd9e594079cf..ebda9c366b2ba 100644 --- a/tools/power/x86/x86_energy_perf_policy/x86_energy_perf_policy.c +++ b/tools/power/x86/x86_energy_perf_policy/x86_energy_perf_policy.c @@ -1241,6 +1241,7 @@ unsigned int get_pkg_num(int cpu) retval = fscanf(fp, "%d\n", &pkg); if (retval != 1) errx(1, "%s: failed to parse", pathname); + fclose(fp); return pkg; } -- 2.43.0