Received: by 2002:ab2:1149:0:b0:1f3:1f8c:d0c6 with SMTP id z9csp21345lqz; Fri, 29 Mar 2024 07:24:13 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVSheBe5Y6dFHL0vRHi3fIA0rzK1Osmd+4TM8qcnWrp8wHXIXhuOD2Sb121M1E6C1hFLBKqGuLwY3RQU0T6NG/yXNA6I1dHPoF1L1ScvA== X-Google-Smtp-Source: AGHT+IEdw83QTvDhwrd4rNXZYlcFc5ynHY4+cpoYfE6GBN40Fn0C6E6qnyCEUUGPt+VQRz+tKaxH X-Received: by 2002:a17:903:41d0:b0:1e2:587:b553 with SMTP id u16-20020a17090341d000b001e20587b553mr2590710ple.6.1711722252972; Fri, 29 Mar 2024 07:24:12 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711722252; cv=pass; d=google.com; s=arc-20160816; b=Fer81EFCgcUELIBCicS3F7p3AzsfHda1Dg1ZZCN17WjFWd0L6J3LeZW0p5yKFxPs7k Yl6iLj/rCQT1q3MqMAxDhIA6LCCYnr0hlyddCpdIY33eag31wI9S7QNq1pAl6+8cHM2i vgkfuhlYJjPKL485N6RUgWWm0neckVV6nl2x5rHV8rEMnotfY/JSrwsM0dshpEAhK9I1 dv60uuV7vVLgKd7vzwfsFaQTyMwGLefpTuICHjrsG80ORZdVRkXzb8/UlA4Z83uupzre wttAT/tMdhLt67bAhXfmNdQKRmXBnxuTAfEtNvc0FxnbV/M/JaSDoda1mhcToQbbypWX K4Sg== 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=AsfWz6LW0sp92ngSd9hODr/w1VJwbqsVzCYTHpzp5xSPCtVZTozKTmK7E2vt22j35Q jwG0HDqm0qDH3wDIvyBG3H26sb161ePIwt+bgdw84xzdLygHge0aLVFOzXDyXC+YPMCf Pymm1x7tIrCilA31ie6yVmkfoIU+CjYpp4DWphBI4owZgWTAEJ3g7sAPiT+nG6cUpKfG 4MsFmbEbrVKZBbSR4wJOVTQTF0mNoFvs5xPnO+H+boEThHY4fsxzxWwn0JNk2vy9bPJb H7rZHdI9ZaR9k9hInpocWCaE4OL0tJ4IjdmNuOfXlkYFe9WFm+cGzksbOC+5YJ14I/x7 oLrA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=ZuPeWIlz; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-124910-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-124910-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id j13-20020a170903028d00b001e0b89a6dbesi3827959plr.387.2024.03.29.07.24.12 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 Mar 2024 07:24:12 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-124910-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=ZuPeWIlz; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-124910-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-124910-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 7DAB2285958 for ; Fri, 29 Mar 2024 14:24:12 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D1FB329E1A5; Fri, 29 Mar 2024 12:46:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="ZuPeWIlz" 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 0235C29D3B4; Fri, 29 Mar 2024 12:46:53 +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=1711716414; cv=none; b=Cu1X53gnhwJ7PW9YHSuELHeMZN2p3IWJiDuyMOVlJqlMG/pWQE/5TbOO41fWHb2k/kDyDg5zPGlrY5sq0v3b1AcDQ/LTGOD/ZMWh/tHl39+M9Ri9+/T3nyxsyiOjE/+3I0EfQI2fy+zZR25Y3JI0yYLsf2cuZJZL61DRoh83F28= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711716414; c=relaxed/simple; bh=Kdyszlwq5JIK92eTlec4mtX/vVJlwIS0I5GaYJWP4a0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=DyktluIAmQe5K+dz1KYs1avj5Nw/ifBHHln7Q1zCQV9rsSgOEPNljjbqeeL7T28GtMrPXlB+Cv5BgUB997oV3xDE8fdzo3qIhPvEzRzGpm1yNOwqfWzHIRNhentphfCG3bJMF4WW63Dt9HgCfORvg6kn1UnhfLgoOJMS13IhCgE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=ZuPeWIlz; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 436C6C43399; Fri, 29 Mar 2024 12:46:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1711716413; bh=Kdyszlwq5JIK92eTlec4mtX/vVJlwIS0I5GaYJWP4a0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ZuPeWIlzK2Gc0hNLQpWZ4qEgDGiaKRULgs051p2Qt6baqJ5qQtLa8ggEcta6xa4CE qo6xYErVpcIP9grADxMzjAZzcDTMoZOuhz2k5vZJYGdUEWLzZbrR8Cb3IYDBC5KkEm a9V8c96Nl1B84UZLw/NN6m32teTAmKF48XGj1PlHfGvab1VA0pJzfdKpwRXtLj5Yi6 XgSwEXmZehq84Kkg+dV8TLW9a+2AnYY32GtQYY3lH43ObQUO2ACjZjJbep6zk9gspt tNRRwMO9iA0Pno/UEQSILJtuIAfHHajEVEUIu9pJU/IIBH4N0ICHAviSlzrNXT/pp5 3k9FByO3TRuzQ== 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.1 26/52] tools/power x86_energy_perf_policy: Fix file leak in get_pkg_num() Date: Fri, 29 Mar 2024 08:45:20 -0400 Message-ID: <20240329124605.3091273-26-sashal@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240329124605.3091273-1-sashal@kernel.org> References: <20240329124605.3091273-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.1.83 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