platform-driver-x86.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH][next] platform/x86: intel_pmc_core: fix unsigned variable compared to less than zero
@ 2021-04-20 12:10 Colin King
  2021-04-20 15:02 ` Hans de Goede
  0 siblings, 1 reply; 2+ messages in thread
From: Colin King @ 2021-04-20 12:10 UTC (permalink / raw)
  To: Rajneesh Bhardwaj, David E Box, Hans de Goede, Mark Gross,
	platform-driver-x86
  Cc: kernel-janitors, linux-kernel

From: Colin Ian King <colin.king@canonical.com>

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")
Fixes: 8074a79fad2e ("platform/x86: intel_pmc_core: Add option to set/clear LPM mode")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
 drivers/platform/x86/intel_pmc_core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/platform/x86/intel_pmc_core.c b/drivers/platform/x86/intel_pmc_core.c
index 3ae00ac85c75..d174aeb492e0 100644
--- a/drivers/platform/x86/intel_pmc_core.c
+++ b/drivers/platform/x86/intel_pmc_core.c
@@ -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;
 
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH][next] platform/x86: intel_pmc_core: fix unsigned variable compared to less than zero
  2021-04-20 12:10 [PATCH][next] platform/x86: intel_pmc_core: fix unsigned variable compared to less than zero Colin King
@ 2021-04-20 15:02 ` Hans de Goede
  0 siblings, 0 replies; 2+ messages in thread
From: Hans de Goede @ 2021-04-20 15:02 UTC (permalink / raw)
  To: Colin King, Rajneesh Bhardwaj, David E Box, Mark Gross,
	platform-driver-x86
  Cc: kernel-janitors, linux-kernel

Hi Colin,

On 4/20/21 2:10 PM, Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
> 
> 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")
> Fixes: 8074a79fad2e ("platform/x86: intel_pmc_core: Add option to set/clear LPM mode")
> Signed-off-by: Colin Ian King <colin.king@canonical.com>

Thank you for the patch, but I already send out the same patch myself
yesterday, so this is a duplicate.

Regards,

Hans



> ---
>  drivers/platform/x86/intel_pmc_core.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/platform/x86/intel_pmc_core.c b/drivers/platform/x86/intel_pmc_core.c
> index 3ae00ac85c75..d174aeb492e0 100644
> --- a/drivers/platform/x86/intel_pmc_core.c
> +++ b/drivers/platform/x86/intel_pmc_core.c
> @@ -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;
>  
> 


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-04-20 15:03 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-20 12:10 [PATCH][next] platform/x86: intel_pmc_core: fix unsigned variable compared to less than zero Colin King
2021-04-20 15:02 ` Hans de Goede

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).