All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] staging: rtl8192u: fix incorrect mask and shift on u8 data
@ 2017-07-21 13:42 ` Colin King
  0 siblings, 0 replies; 6+ messages in thread
From: Colin King @ 2017-07-21 13:42 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Scott Matheina, David S . Miller,
	simran singhal, Johannes Berg, Derek Robson, devel
  Cc: kernel-janitors, linux-kernel

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

The cfg_action bit comes from the high bit of pmsg[4] so the
current mask and shift are in correct and always result in
zero.  Fix this by using the correct mask and shif to get the
correct cfg_action bit value.

Detected by CoverityScan, CID#142890 ("Operands don't affect result")

Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
 drivers/staging/rtl8192u/r819xU_cmdpkt.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/rtl8192u/r819xU_cmdpkt.c b/drivers/staging/rtl8192u/r819xU_cmdpkt.c
index 87ab3ba760fc..ae9a4f1ac8fd 100644
--- a/drivers/staging/rtl8192u/r819xU_cmdpkt.c
+++ b/drivers/staging/rtl8192u/r819xU_cmdpkt.c
@@ -294,7 +294,7 @@ static void cmpk_handle_query_config_rx(struct net_device *dev, u8 *pmsg)
 	 * windows OS. So we have to read the content byte by byte or transfer
 	 * endian type before copy the message copy.
 	 */
-	rx_query_cfg.cfg_action		= (pmsg[4] & 0x80000000) >> 31;
+	rx_query_cfg.cfg_action		= (pmsg[4] & 0x80) >> 7;
 	rx_query_cfg.cfg_type		= (pmsg[4] & 0x60) >> 5;
 	rx_query_cfg.cfg_size		= (pmsg[4] & 0x18) >> 3;
 	rx_query_cfg.cfg_page		= (pmsg[6] & 0x0F) >> 0;
-- 
2.11.0


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

* [PATCH] staging: rtl8192u: fix incorrect mask and shift on u8 data
@ 2017-07-21 13:42 ` Colin King
  0 siblings, 0 replies; 6+ messages in thread
From: Colin King @ 2017-07-21 13:42 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Scott Matheina, David S . Miller,
	simran singhal, Johannes Berg, Derek Robson, devel
  Cc: kernel-janitors, linux-kernel

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

The cfg_action bit comes from the high bit of pmsg[4] so the
current mask and shift are in correct and always result in
zero.  Fix this by using the correct mask and shif to get the
correct cfg_action bit value.

Detected by CoverityScan, CID#142890 ("Operands don't affect result")

Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
 drivers/staging/rtl8192u/r819xU_cmdpkt.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/rtl8192u/r819xU_cmdpkt.c b/drivers/staging/rtl8192u/r819xU_cmdpkt.c
index 87ab3ba760fc..ae9a4f1ac8fd 100644
--- a/drivers/staging/rtl8192u/r819xU_cmdpkt.c
+++ b/drivers/staging/rtl8192u/r819xU_cmdpkt.c
@@ -294,7 +294,7 @@ static void cmpk_handle_query_config_rx(struct net_device *dev, u8 *pmsg)
 	 * windows OS. So we have to read the content byte by byte or transfer
 	 * endian type before copy the message copy.
 	 */
-	rx_query_cfg.cfg_action		= (pmsg[4] & 0x80000000) >> 31;
+	rx_query_cfg.cfg_action		= (pmsg[4] & 0x80) >> 7;
 	rx_query_cfg.cfg_type		= (pmsg[4] & 0x60) >> 5;
 	rx_query_cfg.cfg_size		= (pmsg[4] & 0x18) >> 3;
 	rx_query_cfg.cfg_page		= (pmsg[6] & 0x0F) >> 0;
-- 
2.11.0

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

* [PATCH] staging: rtl8192u: fix incorrect mask when calculating TxPowerLevelCCK
@ 2017-09-05 16:32   ` Colin King
  0 siblings, 0 replies; 6+ messages in thread
From: Colin King @ 2017-09-05 16:32 UTC (permalink / raw)
  To: Greg Kroah-Hartman, simran singhal, Derek Robson, devel
  Cc: kernel-janitors, linux-kernel

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

The mask of 0xff and right shift of 8 bits on ret always results in
a value of 0 for TxPowerLevelCCK.  I believe this should be a mask of
0xff00, however I do not have the hardware at hand to test this out,
so there is a distinct possibility I may be wrong on this.

Detected by CoverityScan CID#1357110 ("Operands don't affect result")

Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
 drivers/staging/rtl8192u/r8192U_core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/rtl8192u/r8192U_core.c b/drivers/staging/rtl8192u/r8192U_core.c
index 46b3f19e0878..ecc887636173 100644
--- a/drivers/staging/rtl8192u/r8192U_core.c
+++ b/drivers/staging/rtl8192u/r8192U_core.c
@@ -2510,7 +2510,7 @@ static int rtl8192_read_eeprom_info(struct net_device *dev)
 				ret = eprom_read(dev, (EEPROM_TxPwIndex_CCK >> 1));
 				if (ret < 0)
 					return ret;
-				priv->EEPROMTxPowerLevelCCK = ((u16)ret & 0xff) >> 8;
+				priv->EEPROMTxPowerLevelCCK = ((u16)ret & 0xff00) >> 8;
 			} else
 				priv->EEPROMTxPowerLevelCCK = 0x10;
 			RT_TRACE(COMP_EPROM, "CCK Tx Power Levl: 0x%02x\n", priv->EEPROMTxPowerLevelCCK);
-- 
2.14.1


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

* [PATCH] staging: rtl8192u: fix incorrect mask when calculating TxPowerLevelCCK
@ 2017-09-05 16:32   ` Colin King
  0 siblings, 0 replies; 6+ messages in thread
From: Colin King @ 2017-09-05 16:32 UTC (permalink / raw)
  To: Greg Kroah-Hartman, simran singhal, Derek Robson, devel
  Cc: kernel-janitors, linux-kernel

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

The mask of 0xff and right shift of 8 bits on ret always results in
a value of 0 for TxPowerLevelCCK.  I believe this should be a mask of
0xff00, however I do not have the hardware at hand to test this out,
so there is a distinct possibility I may be wrong on this.

Detected by CoverityScan CID#1357110 ("Operands don't affect result")

Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
 drivers/staging/rtl8192u/r8192U_core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/rtl8192u/r8192U_core.c b/drivers/staging/rtl8192u/r8192U_core.c
index 46b3f19e0878..ecc887636173 100644
--- a/drivers/staging/rtl8192u/r8192U_core.c
+++ b/drivers/staging/rtl8192u/r8192U_core.c
@@ -2510,7 +2510,7 @@ static int rtl8192_read_eeprom_info(struct net_device *dev)
 				ret = eprom_read(dev, (EEPROM_TxPwIndex_CCK >> 1));
 				if (ret < 0)
 					return ret;
-				priv->EEPROMTxPowerLevelCCK = ((u16)ret & 0xff) >> 8;
+				priv->EEPROMTxPowerLevelCCK = ((u16)ret & 0xff00) >> 8;
 			} else
 				priv->EEPROMTxPowerLevelCCK = 0x10;
 			RT_TRACE(COMP_EPROM, "CCK Tx Power Levl: 0x%02x\n", priv->EEPROMTxPowerLevelCCK);
-- 
2.14.1

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

* Re: [PATCH] staging: rtl8192u: fix incorrect mask when calculating TxPowerLevelCCK
  2017-09-05 16:32   ` Colin King
@ 2017-09-05 17:00     ` walter harms
  -1 siblings, 0 replies; 6+ messages in thread
From: walter harms @ 2017-09-05 17:00 UTC (permalink / raw)
  To: Colin King
  Cc: Greg Kroah-Hartman, simran singhal, Derek Robson, devel,
	kernel-janitors, linux-kernel



Am 05.09.2017 18:32, schrieb Colin King:
> From: Colin Ian King <colin.king@canonical.com>
> 
> The mask of 0xff and right shift of 8 bits on ret always results in
> a value of 0 for TxPowerLevelCCK.  I believe this should be a mask of
> 0xff00, however I do not have the hardware at hand to test this out,
> so there is a distinct possibility I may be wrong on this.
> 
> Detected by CoverityScan CID#1357110 ("Operands don't affect result")
> 
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
>  drivers/staging/rtl8192u/r8192U_core.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/staging/rtl8192u/r8192U_core.c b/drivers/staging/rtl8192u/r8192U_core.c
> index 46b3f19e0878..ecc887636173 100644
> --- a/drivers/staging/rtl8192u/r8192U_core.c
> +++ b/drivers/staging/rtl8192u/r8192U_core.c
> @@ -2510,7 +2510,7 @@ static int rtl8192_read_eeprom_info(struct net_device *dev)
>  				ret = eprom_read(dev, (EEPROM_TxPwIndex_CCK >> 1));
>  				if (ret < 0)
>  					return ret;
> -				priv->EEPROMTxPowerLevelCCK = ((u16)ret & 0xff) >> 8;
> +				priv->EEPROMTxPowerLevelCCK = ((u16)ret & 0xff00) >> 8;

Is there any need for the mask ?
(u16) will already reduce ret to 16 bit, the >>8 will shift the lower bits into nirwana

re,
 wh

>  			} else
>  				priv->EEPROMTxPowerLevelCCK = 0x10;
>  			RT_TRACE(COMP_EPROM, "CCK Tx Power Levl: 0x%02x\n", priv->EEPROMTxPowerLevelCCK);

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

* Re: [PATCH] staging: rtl8192u: fix incorrect mask when calculating TxPowerLevelCCK
@ 2017-09-05 17:00     ` walter harms
  0 siblings, 0 replies; 6+ messages in thread
From: walter harms @ 2017-09-05 17:00 UTC (permalink / raw)
  To: Colin King
  Cc: Greg Kroah-Hartman, simran singhal, Derek Robson, devel,
	kernel-janitors, linux-kernel



Am 05.09.2017 18:32, schrieb Colin King:
> From: Colin Ian King <colin.king@canonical.com>
> 
> The mask of 0xff and right shift of 8 bits on ret always results in
> a value of 0 for TxPowerLevelCCK.  I believe this should be a mask of
> 0xff00, however I do not have the hardware at hand to test this out,
> so there is a distinct possibility I may be wrong on this.
> 
> Detected by CoverityScan CID#1357110 ("Operands don't affect result")
> 
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
>  drivers/staging/rtl8192u/r8192U_core.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/staging/rtl8192u/r8192U_core.c b/drivers/staging/rtl8192u/r8192U_core.c
> index 46b3f19e0878..ecc887636173 100644
> --- a/drivers/staging/rtl8192u/r8192U_core.c
> +++ b/drivers/staging/rtl8192u/r8192U_core.c
> @@ -2510,7 +2510,7 @@ static int rtl8192_read_eeprom_info(struct net_device *dev)
>  				ret = eprom_read(dev, (EEPROM_TxPwIndex_CCK >> 1));
>  				if (ret < 0)
>  					return ret;
> -				priv->EEPROMTxPowerLevelCCK = ((u16)ret & 0xff) >> 8;
> +				priv->EEPROMTxPowerLevelCCK = ((u16)ret & 0xff00) >> 8;

Is there any need for the mask ?
(u16) will already reduce ret to 16 bit, the >>8 will shift the lower bits into nirwana

re,
 wh

>  			} else
>  				priv->EEPROMTxPowerLevelCCK = 0x10;
>  			RT_TRACE(COMP_EPROM, "CCK Tx Power Levl: 0x%02x\n", priv->EEPROMTxPowerLevelCCK);

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

end of thread, other threads:[~2017-09-05 17:00 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-07-21 13:42 [PATCH] staging: rtl8192u: fix incorrect mask and shift on u8 data Colin King
2017-07-21 13:42 ` Colin King
2017-09-05 16:32 ` [PATCH] staging: rtl8192u: fix incorrect mask when calculating TxPowerLevelCCK Colin King
2017-09-05 16:32   ` Colin King
2017-09-05 17:00   ` walter harms
2017-09-05 17:00     ` walter harms

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.