linux/drivers/powercap
Sumeet Pawnikar c618c4ccb7 powercap: fix sscanf() error return value handling
[ Upstream commit efc4c35b74 ]

Fix inconsistent error handling for sscanf() return value check.

Implicit boolean conversion is used instead of explicit return
value checks. The code checks if (!sscanf(...)) which is incorrect
because:
 1. sscanf returns the number of successfully parsed items
 2. On success, it returns 1 (one item passed)
 3. On failure, it returns 0 or EOF
 4. The check 'if (!sscanf(...))' is wrong because it treats
    success (1) as failure

All occurrences of sscanf() now uses explicit return value check.
With this behavior it returns '-EINVAL' when parsing fails (returns
0 or EOF), and continues when parsing succeeds (returns 1).

Signed-off-by: Sumeet Pawnikar <sumeet4linux@gmail.com>
[ rjw: Subject and changelog edits ]
Link: https://patch.msgid.link/20251207151549.202452-1-sumeet4linux@gmail.com
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
History 2026-01-19 13:10:19 +01:00
..
dtpm.c powercap/drivers/dtpm: Fix root node initialization 2021-03-01 17:43:29 +01:00
dtpm_cpu.c powercap/drivers/dtpm: Fix size of object being allocated 2021-01-07 18:16:03 +01:00
idle_inject.c powercap: include header to fix -Wmissing-prototypes 2020-09-25 16:46:01 +02:00
intel_rapl_common.c powercap: intel_rapl: Do not change CLAMPING bit if ENABLE bit cannot be changed 2025-08-28 16:24:03 +02:00
intel_rapl_msr.c powercap: RAPL: fix invalid initialization for pl4_supported field 2024-10-17 15:11:09 +02:00
Kconfig powercap: RAPL: Fix CONFIG_IOSF_MBI dependency 2023-07-23 13:46:46 +02:00
Makefile powercap/drivers/dtpm: Add CPU energy model based support 2020-12-22 19:50:40 +01:00
powercap_sys.c powercap: fix sscanf() error return value handling 2026-01-19 13:10:19 +01:00