platform/x86: intel_pmc_core: fix unsigned variable compared to less than zero
Subsystems (2)
PATCH 1/1 platform/x86: intel_pmc_core: fix unsigned variable compared to less than zero
From: Colin Ian King <[email protected]>
The check for ret < 0 is always false because ret is a (unsigned) size_t and not a (signed) ssize_t, hence simple_write_to_buffer failures are never detected. Fix this by making ret a ssize_t
Addresses-Coverity: ("Unsigned compared against 0")
--- drivers/platform/x86/intel_pmc_core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/platform/x86/intel_pmc_core.c +1 -1
@@ -1360,7 +1360,7 @@ static ssize_t pmc_core_lpm_latch_mode_write(struct file *file,struct pmc_dev *pmcdev = s->private;bool clear = false, c10 = false;unsigned char buf[8 ]; -size_t ret; +ssize_t ret;int idx, m, mode;u32 reg;
Signature · 1 line
2.30.2
Hi Colin,
Quoted 9 lines · Colin King
From: Colin Ian King <[email protected]>
The check for ret < 0 is always false because ret is a (unsigned)
size_tand not a (signed)ssize_t, hencesimple_write_to_bufferfailures are never detected. Fix this by making ret assize_tAddresses-Coverity: ("Unsigned compared against 0")
Fixes 8074a79fad2e ("platform/x86: intel_pmc_core: Add option to set/clear LPM mode")Signed-off-by Colin Ian King <[email protected]>
Thank you for the patch, but I already send out the same patch myself yesterday, so this is a duplicate.
Regards,
Hans
Quoted 18 lines
--- drivers/platform/x86/intel_pmc_core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/platform/x86/intel_pmc_core.c +1
-1@@ -1360,7 +1360,7 @@ static ssize_t pmc_core_lpm_latch_mode_write(struct file *file,struct pmc_dev *pmcdev = s->private;bool clear = false, c10 = false;unsigned char buf[8 ]; -size_t ret; +ssize_t ret;int idx, m, mode;u32 reg;