All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH][next] ipmi: kcs_bmc_aspeed: Fix less than zero comparison of a unsigned int
@ 2021-06-16 16:29 ` Colin King
  0 siblings, 0 replies; 6+ messages in thread
From: Colin King @ 2021-06-16 16:29 UTC (permalink / raw)
  To: Corey Minyard, Joel Stanley, Andrew Jeffery, openipmi-developer,
	linux-arm-kernel, linux-aspeed
  Cc: kernel-janitors, linux-kernel

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

The comparisons of the unsigned int hw_type to less than zero always
false because it is unsigned. Fix this by using an int for the
assignment and less than zero check.

Addresses-Coverity: ("Unsigned compared against 0")
Fixes: 9d2df9a0ad80 ("ipmi: kcs_bmc_aspeed: Implement KCS SerIRQ configuration")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
 drivers/char/ipmi/kcs_bmc_aspeed.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/drivers/char/ipmi/kcs_bmc_aspeed.c b/drivers/char/ipmi/kcs_bmc_aspeed.c
index 0401089f8895..92a37b33494c 100644
--- a/drivers/char/ipmi/kcs_bmc_aspeed.c
+++ b/drivers/char/ipmi/kcs_bmc_aspeed.c
@@ -301,13 +301,15 @@ static inline int aspeed_kcs_map_serirq_type(u32 dt_type)
 static int aspeed_kcs_config_upstream_irq(struct aspeed_kcs_bmc *priv, u32 id, u32 dt_type)
 {
 	unsigned int mask, val, hw_type;
+	int ret;
 
 	if (id > 15)
 		return -EINVAL;
 
-	hw_type = aspeed_kcs_map_serirq_type(dt_type);
-	if (hw_type < 0)
-		return hw_type;
+	ret = aspeed_kcs_map_serirq_type(dt_type);
+	if (ret < 0)
+		return ret;
+	hw_type = ret;
 
 	priv->upstream_irq.mode = aspeed_kcs_irq_serirq;
 	priv->upstream_irq.id = id;
-- 
2.31.1


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

* [PATCH][next] ipmi: kcs_bmc_aspeed: Fix less than zero comparison of a unsigned int
@ 2021-06-16 16:29 ` Colin King
  0 siblings, 0 replies; 6+ messages in thread
From: Colin King @ 2021-06-16 16:29 UTC (permalink / raw)
  To: Corey Minyard, Joel Stanley, Andrew Jeffery, openipmi-developer,
	linux-arm-kernel, linux-aspeed
  Cc: kernel-janitors, linux-kernel

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

The comparisons of the unsigned int hw_type to less than zero always
false because it is unsigned. Fix this by using an int for the
assignment and less than zero check.

Addresses-Coverity: ("Unsigned compared against 0")
Fixes: 9d2df9a0ad80 ("ipmi: kcs_bmc_aspeed: Implement KCS SerIRQ configuration")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
 drivers/char/ipmi/kcs_bmc_aspeed.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/drivers/char/ipmi/kcs_bmc_aspeed.c b/drivers/char/ipmi/kcs_bmc_aspeed.c
index 0401089f8895..92a37b33494c 100644
--- a/drivers/char/ipmi/kcs_bmc_aspeed.c
+++ b/drivers/char/ipmi/kcs_bmc_aspeed.c
@@ -301,13 +301,15 @@ static inline int aspeed_kcs_map_serirq_type(u32 dt_type)
 static int aspeed_kcs_config_upstream_irq(struct aspeed_kcs_bmc *priv, u32 id, u32 dt_type)
 {
 	unsigned int mask, val, hw_type;
+	int ret;
 
 	if (id > 15)
 		return -EINVAL;
 
-	hw_type = aspeed_kcs_map_serirq_type(dt_type);
-	if (hw_type < 0)
-		return hw_type;
+	ret = aspeed_kcs_map_serirq_type(dt_type);
+	if (ret < 0)
+		return ret;
+	hw_type = ret;
 
 	priv->upstream_irq.mode = aspeed_kcs_irq_serirq;
 	priv->upstream_irq.id = id;
-- 
2.31.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH][next] ipmi: kcs_bmc_aspeed: Fix less than zero comparison of a unsigned int
  2021-06-16 16:29 ` Colin King
@ 2021-06-16 19:02   ` Corey Minyard
  -1 siblings, 0 replies; 6+ messages in thread
From: Corey Minyard @ 2021-06-16 19:02 UTC (permalink / raw)
  To: Colin King
  Cc: Joel Stanley, Andrew Jeffery, openipmi-developer,
	linux-arm-kernel, linux-aspeed, kernel-janitors, linux-kernel

On Wed, Jun 16, 2021 at 05:29:13PM +0100, Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
> 
> The comparisons of the unsigned int hw_type to less than zero always
> false because it is unsigned. Fix this by using an int for the
> assignment and less than zero check.

Thanks, I added this to my tree.

-corey

> 
> Addresses-Coverity: ("Unsigned compared against 0")
> Fixes: 9d2df9a0ad80 ("ipmi: kcs_bmc_aspeed: Implement KCS SerIRQ configuration")
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
>  drivers/char/ipmi/kcs_bmc_aspeed.c | 8 +++++---
>  1 file changed, 5 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/char/ipmi/kcs_bmc_aspeed.c b/drivers/char/ipmi/kcs_bmc_aspeed.c
> index 0401089f8895..92a37b33494c 100644
> --- a/drivers/char/ipmi/kcs_bmc_aspeed.c
> +++ b/drivers/char/ipmi/kcs_bmc_aspeed.c
> @@ -301,13 +301,15 @@ static inline int aspeed_kcs_map_serirq_type(u32 dt_type)
>  static int aspeed_kcs_config_upstream_irq(struct aspeed_kcs_bmc *priv, u32 id, u32 dt_type)
>  {
>  	unsigned int mask, val, hw_type;
> +	int ret;
>  
>  	if (id > 15)
>  		return -EINVAL;
>  
> -	hw_type = aspeed_kcs_map_serirq_type(dt_type);
> -	if (hw_type < 0)
> -		return hw_type;
> +	ret = aspeed_kcs_map_serirq_type(dt_type);
> +	if (ret < 0)
> +		return ret;
> +	hw_type = ret;
>  
>  	priv->upstream_irq.mode = aspeed_kcs_irq_serirq;
>  	priv->upstream_irq.id = id;
> -- 
> 2.31.1
> 

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

* Re: [PATCH][next] ipmi: kcs_bmc_aspeed: Fix less than zero comparison of a unsigned int
@ 2021-06-16 19:02   ` Corey Minyard
  0 siblings, 0 replies; 6+ messages in thread
From: Corey Minyard @ 2021-06-16 19:02 UTC (permalink / raw)
  To: Colin King
  Cc: Joel Stanley, Andrew Jeffery, openipmi-developer,
	linux-arm-kernel, linux-aspeed, kernel-janitors, linux-kernel

On Wed, Jun 16, 2021 at 05:29:13PM +0100, Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
> 
> The comparisons of the unsigned int hw_type to less than zero always
> false because it is unsigned. Fix this by using an int for the
> assignment and less than zero check.

Thanks, I added this to my tree.

-corey

> 
> Addresses-Coverity: ("Unsigned compared against 0")
> Fixes: 9d2df9a0ad80 ("ipmi: kcs_bmc_aspeed: Implement KCS SerIRQ configuration")
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
>  drivers/char/ipmi/kcs_bmc_aspeed.c | 8 +++++---
>  1 file changed, 5 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/char/ipmi/kcs_bmc_aspeed.c b/drivers/char/ipmi/kcs_bmc_aspeed.c
> index 0401089f8895..92a37b33494c 100644
> --- a/drivers/char/ipmi/kcs_bmc_aspeed.c
> +++ b/drivers/char/ipmi/kcs_bmc_aspeed.c
> @@ -301,13 +301,15 @@ static inline int aspeed_kcs_map_serirq_type(u32 dt_type)
>  static int aspeed_kcs_config_upstream_irq(struct aspeed_kcs_bmc *priv, u32 id, u32 dt_type)
>  {
>  	unsigned int mask, val, hw_type;
> +	int ret;
>  
>  	if (id > 15)
>  		return -EINVAL;
>  
> -	hw_type = aspeed_kcs_map_serirq_type(dt_type);
> -	if (hw_type < 0)
> -		return hw_type;
> +	ret = aspeed_kcs_map_serirq_type(dt_type);
> +	if (ret < 0)
> +		return ret;
> +	hw_type = ret;
>  
>  	priv->upstream_irq.mode = aspeed_kcs_irq_serirq;
>  	priv->upstream_irq.id = id;
> -- 
> 2.31.1
> 

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH][next] ipmi: kcs_bmc_aspeed: Fix less than zero comparison of a unsigned int
  2021-06-16 16:29 ` Colin King
@ 2021-06-16 23:03   ` Andrew Jeffery
  -1 siblings, 0 replies; 6+ messages in thread
From: Andrew Jeffery @ 2021-06-16 23:03 UTC (permalink / raw)
  To: Colin King, Corey Minyard, Joel Stanley, openipmi-developer,
	linux-arm-kernel, linux-aspeed
  Cc: kernel-janitors, linux-kernel



On Thu, 17 Jun 2021, at 01:59, Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
> 
> The comparisons of the unsigned int hw_type to less than zero always
> false because it is unsigned. Fix this by using an int for the
> assignment and less than zero check.
> 

> Addresses-Coverity: ("Unsigned compared against 0")
> Fixes: 9d2df9a0ad80 ("ipmi: kcs_bmc_aspeed: Implement KCS SerIRQ configuration")
> Signed-off-by: Colin Ian King <colin.king@canonical.com>

Thanks for catching that.

Andrew

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

* Re: [PATCH][next] ipmi: kcs_bmc_aspeed: Fix less than zero comparison of a unsigned int
@ 2021-06-16 23:03   ` Andrew Jeffery
  0 siblings, 0 replies; 6+ messages in thread
From: Andrew Jeffery @ 2021-06-16 23:03 UTC (permalink / raw)
  To: Colin King, Corey Minyard, Joel Stanley, openipmi-developer,
	linux-arm-kernel, linux-aspeed
  Cc: kernel-janitors, linux-kernel



On Thu, 17 Jun 2021, at 01:59, Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
> 
> The comparisons of the unsigned int hw_type to less than zero always
> false because it is unsigned. Fix this by using an int for the
> assignment and less than zero check.
> 

> Addresses-Coverity: ("Unsigned compared against 0")
> Fixes: 9d2df9a0ad80 ("ipmi: kcs_bmc_aspeed: Implement KCS SerIRQ configuration")
> Signed-off-by: Colin Ian King <colin.king@canonical.com>

Thanks for catching that.

Andrew

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

end of thread, other threads:[~2021-06-16 23:17 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-16 16:29 [PATCH][next] ipmi: kcs_bmc_aspeed: Fix less than zero comparison of a unsigned int Colin King
2021-06-16 16:29 ` Colin King
2021-06-16 19:02 ` Corey Minyard
2021-06-16 19:02   ` Corey Minyard
2021-06-16 23:03 ` Andrew Jeffery
2021-06-16 23:03   ` Andrew Jeffery

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.