cw1200: Fix a signedness bug in cw1200_load_firmware()
Subsystems (2)
PATCH 1/1 cw1200: Fix a signedness bug in cw1200_load_firmware()
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.
--- drivers/net/wireless/st/cw1200/fwio.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/wireless/st/cw1200/fwio.c +1 -1
@@ -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;
Signature · 1 line
2.20.1
Quoted 14 lines · Dan Carpenter
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 <[email protected]>--- drivers/net/wireless/st/cw1200/fwio.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/net/wireless/st/cw1200/fwio.c +0
-0
drivers/net/wireless/st/cw1200/fwio.c int cw1200_load_firmware(struct cw1200_common *priv) · line 327
Quoted 8 lines
drivers/net/wireless/st/cw1200/fwio.c +1
-1@@ -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?
Signature · 1 line
Kalle Valo
PATCH v2 1/1 cw1200: Fix a signedness bug in cw1200_load_firmware()
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.
---
v2: better style and preserve the error code.
drivers/net/wireless/st/cw1200/fwio.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/net/wireless/st/cw1200/fwio.c +3 -3
@@ -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,
Signature · 1 line
2.20.1
Quoted 18 lines · Dan Carpenter
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 <[email protected]>---
v2: better style and preserve the error code.drivers/net/wireless/st/cw1200/fwio.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)drivers/net/wireless/st/cw1200/fwio.c +0
-0@@ -320,12 +320,12 @@ int cw1200_load_firmware(struct cw1200_common *priv) goto out; }
drivers/net/wireless/st/cw1200/fwio.c int cw1200_load_firmware(struct cw1200_common *priv) · line 328
Quoted 10 lines
drivers/net/wireless/st/cw1200/fwio.c +3
-3- 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.
Signature · 1 line
https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches
Quoted 5 lines · Dan Carpenter
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 <[email protected]>
Patch applied to wireless-drivers-next.git, thanks.
4a50d454502f cw1200: Fix a signedness bug in cw1200_load_firmware()
Signature · 3 lines
https://patchwork.kernel.org/patch/11168561/ https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches