linux-wireless.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] cw1200: Fix a signedness bug in cw1200_load_firmware()
@ 2019-09-25 10:59 Dan Carpenter
  2019-09-25 11:06 ` Kalle Valo
  0 siblings, 1 reply; 5+ messages in thread
From: Dan Carpenter @ 2019-09-25 10:59 UTC (permalink / raw)
  To: Solomon Peachy; +Cc: Kalle Valo, linux-wireless, kernel-janitors

The "priv->hw_type" is an enum and in this context GCC will treat it
as an unsigned int so the error handling will never trigger.

Fixes: a910e4a94f69 ("cw1200: add driver for the ST-E CW1100 & CW1200 WLAN chipsets")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
 drivers/net/wireless/st/cw1200/fwio.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/wireless/st/cw1200/fwio.c b/drivers/net/wireless/st/cw1200/fwio.c
index 6574e78e05ea..da767c33dfbb 100644
--- a/drivers/net/wireless/st/cw1200/fwio.c
+++ b/drivers/net/wireless/st/cw1200/fwio.c
@@ -321,7 +321,7 @@ int cw1200_load_firmware(struct cw1200_common *priv)
 	}
 
 	priv->hw_type = cw1200_get_hw_type(val32, &major_revision);
-	if (priv->hw_type < 0) {
+	if ((int)priv->hw_type < 0) {
 		pr_err("Can't deduce hardware type.\n");
 		ret = -ENOTSUPP;
 		goto out;
-- 
2.20.1


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

* Re: [PATCH] cw1200: Fix a signedness bug in cw1200_load_firmware()
  2019-09-25 10:59 [PATCH] cw1200: Fix a signedness bug in cw1200_load_firmware() Dan Carpenter
@ 2019-09-25 11:06 ` Kalle Valo
  2019-10-01 11:45   ` [PATCH v2] " Dan Carpenter
  0 siblings, 1 reply; 5+ messages in thread
From: Kalle Valo @ 2019-09-25 11:06 UTC (permalink / raw)
  To: Dan Carpenter; +Cc: Solomon Peachy, linux-wireless, kernel-janitors

Dan Carpenter <dan.carpenter@oracle.com> writes:

> The "priv->hw_type" is an enum and in this context GCC will treat it
> as an unsigned int so the error handling will never trigger.
>
> Fixes: a910e4a94f69 ("cw1200: add driver for the ST-E CW1100 & CW1200 WLAN chipsets")
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> ---
>  drivers/net/wireless/st/cw1200/fwio.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/net/wireless/st/cw1200/fwio.c b/drivers/net/wireless/st/cw1200/fwio.c
> index 6574e78e05ea..da767c33dfbb 100644
> --- a/drivers/net/wireless/st/cw1200/fwio.c
> +++ b/drivers/net/wireless/st/cw1200/fwio.c
> @@ -321,7 +321,7 @@ int cw1200_load_firmware(struct cw1200_common *priv)
>  	}
>  
>  	priv->hw_type = cw1200_get_hw_type(val32, &major_revision);
> -	if (priv->hw_type < 0) {
> +	if ((int)priv->hw_type < 0) {
>  		pr_err("Can't deduce hardware type.\n");
>  		ret = -ENOTSUPP;
>  		goto out;

Isn't there any cleaner way to fix this? Like having 'int ret' variable
and assign to priv->hw_type after the error handling?

-- 
Kalle Valo

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

* [PATCH v2] cw1200: Fix a signedness bug in cw1200_load_firmware()
  2019-09-25 11:06 ` Kalle Valo
@ 2019-10-01 11:45   ` Dan Carpenter
  2019-10-01 12:02     ` Kalle Valo
  2019-10-02  4:35     ` Kalle Valo
  0 siblings, 2 replies; 5+ messages in thread
From: Dan Carpenter @ 2019-10-01 11:45 UTC (permalink / raw)
  To: Solomon Peachy; +Cc: Kalle Valo, linux-wireless, kernel-janitors

The "priv->hw_type" is an enum and in this context GCC will treat it
as an unsigned int so the error handling will never trigger.

Fixes: a910e4a94f69 ("cw1200: add driver for the ST-E CW1100 & CW1200 WLAN chipsets")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
v2: better style and preserve the error code.

 drivers/net/wireless/st/cw1200/fwio.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/net/wireless/st/cw1200/fwio.c b/drivers/net/wireless/st/cw1200/fwio.c
index 6574e78e05ea..2a03dc533b6a 100644
--- a/drivers/net/wireless/st/cw1200/fwio.c
+++ b/drivers/net/wireless/st/cw1200/fwio.c
@@ -320,12 +320,12 @@ int cw1200_load_firmware(struct cw1200_common *priv)
 		goto out;
 	}
 
-	priv->hw_type = cw1200_get_hw_type(val32, &major_revision);
-	if (priv->hw_type < 0) {
+	ret = cw1200_get_hw_type(val32, &major_revision);
+	if (ret < 0) {
 		pr_err("Can't deduce hardware type.\n");
-		ret = -ENOTSUPP;
 		goto out;
 	}
+	priv->hw_type = ret;
 
 	/* Set DPLL Reg value, and read back to confirm writes work */
 	ret = cw1200_reg_write_32(priv, ST90TDS_TSET_GEN_R_W_REG_ID,
-- 
2.20.1


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

* Re: [PATCH v2] cw1200: Fix a signedness bug in cw1200_load_firmware()
  2019-10-01 11:45   ` [PATCH v2] " Dan Carpenter
@ 2019-10-01 12:02     ` Kalle Valo
  2019-10-02  4:35     ` Kalle Valo
  1 sibling, 0 replies; 5+ messages in thread
From: Kalle Valo @ 2019-10-01 12:02 UTC (permalink / raw)
  To: Dan Carpenter; +Cc: Solomon Peachy, linux-wireless, kernel-janitors

Dan Carpenter <dan.carpenter@oracle.com> writes:

> The "priv->hw_type" is an enum and in this context GCC will treat it
> as an unsigned int so the error handling will never trigger.
>
> Fixes: a910e4a94f69 ("cw1200: add driver for the ST-E CW1100 & CW1200 WLAN chipsets")
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> ---
> v2: better style and preserve the error code.
>
>  drivers/net/wireless/st/cw1200/fwio.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/net/wireless/st/cw1200/fwio.c b/drivers/net/wireless/st/cw1200/fwio.c
> index 6574e78e05ea..2a03dc533b6a 100644
> --- a/drivers/net/wireless/st/cw1200/fwio.c
> +++ b/drivers/net/wireless/st/cw1200/fwio.c
> @@ -320,12 +320,12 @@ int cw1200_load_firmware(struct cw1200_common *priv)
>  		goto out;
>  	}
>  
> -	priv->hw_type = cw1200_get_hw_type(val32, &major_revision);
> -	if (priv->hw_type < 0) {
> +	ret = cw1200_get_hw_type(val32, &major_revision);
> +	if (ret < 0) {
>  		pr_err("Can't deduce hardware type.\n");
> -		ret = -ENOTSUPP;
>  		goto out;
>  	}
> +	priv->hw_type = ret;

Thanks, this is indeed much better.

-- 
https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches

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

* Re: [PATCH v2] cw1200: Fix a signedness bug in cw1200_load_firmware()
  2019-10-01 11:45   ` [PATCH v2] " Dan Carpenter
  2019-10-01 12:02     ` Kalle Valo
@ 2019-10-02  4:35     ` Kalle Valo
  1 sibling, 0 replies; 5+ messages in thread
From: Kalle Valo @ 2019-10-02  4:35 UTC (permalink / raw)
  To: Dan Carpenter; +Cc: Solomon Peachy, linux-wireless, kernel-janitors

Dan Carpenter <dan.carpenter@oracle.com> wrote:

> The "priv->hw_type" is an enum and in this context GCC will treat it
> as an unsigned int so the error handling will never trigger.
> 
> Fixes: a910e4a94f69 ("cw1200: add driver for the ST-E CW1100 & CW1200 WLAN chipsets")
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>

Patch applied to wireless-drivers-next.git, thanks.

4a50d454502f cw1200: Fix a signedness bug in cw1200_load_firmware()

-- 
https://patchwork.kernel.org/patch/11168561/

https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches


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

end of thread, other threads:[~2019-10-02  4:35 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-09-25 10:59 [PATCH] cw1200: Fix a signedness bug in cw1200_load_firmware() Dan Carpenter
2019-09-25 11:06 ` Kalle Valo
2019-10-01 11:45   ` [PATCH v2] " Dan Carpenter
2019-10-01 12:02     ` Kalle Valo
2019-10-02  4:35     ` Kalle Valo

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).