]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
perf hwmon_pmu: Fix uninitialized variable warning
authorMichal Suchanek <msuchanek@suse.de>
Wed, 22 Oct 2025 10:38:35 +0000 (12:38 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 18 Dec 2025 13:02:40 +0000 (14:02 +0100)
commitcc12e90519c287c43de32dfbd6122fae5213bef7
tree3557bb06c750dc6f61dcbadd2d22378397c997b5
parentbd55d00190673cbf609528fe3d4f8dc221a5226e
perf hwmon_pmu: Fix uninitialized variable warning

[ Upstream commit 2fee899c068c159e486e62623afe9e2a4975bd79 ]

The line_len is only set on success. Check the return value instead.

 util/hwmon_pmu.c: In function ‘perf_pmus__read_hwmon_pmus’:
 util/hwmon_pmu.c:742:20: warning: ‘line_len’ may be used uninitialized [-Wmaybe-uninitialized]
   742 |                 if (line_len > 0 && line[line_len - 1] == '\n')
       |                    ^
 util/hwmon_pmu.c:719:24: note: ‘line_len’ was declared here
   719 |                 size_t line_len;

Fixes: 53cc0b351ec9 ("perf hwmon_pmu: Add a tool PMU exposing events from hwmon in sysfs")
Signed-off-by: Michal Suchanek <msuchanek@suse.de>
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
tools/perf/util/hwmon_pmu.c