All of lore.kernel.org
 help / color / mirror / Atom feed
From: Atul Gopinathan <atulgopinathan@gmail.com>
To: gregkh@linuxfoundation.org
Cc: gustavo@embeddedor.com, tiwai@suse.de,
	devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org,
	Atul Gopinathan <atulgopinathan@gmail.com>
Subject: [PATCH 2/2] staging: rtl8192e: Change state information from u16 to u8
Date: Sat, 20 Feb 2021 23:51:55 +0530	[thread overview]
Message-ID: <20210220182154.9457-2-atulgopinathan@gmail.com> (raw)
In-Reply-To: <20210220182154.9457-1-atulgopinathan@gmail.com>

The "CcxRmState" field in struct "rtllib_network" is defined
as a u16 array of size 2 (so, 4 bytes in total).

But the operations performed on this array throughout the code
base (in rtl8192e/) are all in byte size 2 indicating that this
array's type was defined wrongly.

There are two situation were u16 type of this field could yield
incorrect behaviour:

1. In rtllib_rx.c:1970:
memcpy(network->CcxRmState, &info_element->data[4], 2);

Here last 2 bytes (index 4 and 5) from the info_element->data[]
array are meant to be copied into CcxRmState[].
Note that "data" array here is an array of type u8.

2. In function "update_network()" in staging/rtl8192e/rtllib_rx.c:
memcpy(dst->CcxRmState, src->CcxRmState, 2);

Here again, only 2 bytes are copied from the source state to
destination state.

There are no instances of "CcxRmState" requiring u16 data type.
Here is the output of "grep -IRn 'CcxRmState'" on the rtl8192e/
directory for reviewing:

rtllib_rx.c:1970:			memcpy(network->CcxRmState, &info_element->data[4], 2);
rtllib_rx.c:1971:			if (network->CcxRmState[0] != 0)
rtllib_rx.c:1975:			network->MBssidMask = network->CcxRmState[1] & 0x07;
rtllib_rx.c:2520:	memcpy(dst->CcxRmState, src->CcxRmState, 2);
rtllib.h:1108:	u8	CcxRmState[2];

//Note: The last line of output is my commit to this patch (u8 instead
of u16).

Signed-off-by: Atul Gopinathan <atulgopinathan@gmail.com>
---
 drivers/staging/rtl8192e/rtllib.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/rtl8192e/rtllib.h b/drivers/staging/rtl8192e/rtllib.h
index b84f00b8d18b..4cabaf21c1ca 100644
--- a/drivers/staging/rtl8192e/rtllib.h
+++ b/drivers/staging/rtl8192e/rtllib.h
@@ -1101,15 +1101,15 @@ struct rtllib_network {
 	u8 hidden_ssid[IW_ESSID_MAX_SIZE + 1];
 	u8 hidden_ssid_len;
 	struct rtllib_qos_data qos_data;
 
 	bool	bWithAironetIE;
 	bool	bCkipSupported;
 	bool	bCcxRmEnable;
-	u16	CcxRmState[2];
+	u8	CcxRmState[2];
 	bool	bMBssidValid;
 	u8	MBssidMask;
 	u8	MBssid[ETH_ALEN];
 	bool	bWithCcxVerNum;
 	u8	BssCcxVerNumber;
 	/* These are network statistics */
 	struct rtllib_rx_stats stats;
-- 
2.27.0


WARNING: multiple messages have this Message-ID (diff)
From: Atul Gopinathan <atulgopinathan@gmail.com>
To: gregkh@linuxfoundation.org
Cc: tiwai@suse.de, devel@driverdev.osuosl.org,
	Atul Gopinathan <atulgopinathan@gmail.com>,
	linux-kernel@vger.kernel.org, gustavo@embeddedor.com
Subject: [PATCH 2/2] staging: rtl8192e: Change state information from u16 to u8
Date: Sat, 20 Feb 2021 23:51:55 +0530	[thread overview]
Message-ID: <20210220182154.9457-2-atulgopinathan@gmail.com> (raw)
In-Reply-To: <20210220182154.9457-1-atulgopinathan@gmail.com>

The "CcxRmState" field in struct "rtllib_network" is defined
as a u16 array of size 2 (so, 4 bytes in total).

But the operations performed on this array throughout the code
base (in rtl8192e/) are all in byte size 2 indicating that this
array's type was defined wrongly.

There are two situation were u16 type of this field could yield
incorrect behaviour:

1. In rtllib_rx.c:1970:
memcpy(network->CcxRmState, &info_element->data[4], 2);

Here last 2 bytes (index 4 and 5) from the info_element->data[]
array are meant to be copied into CcxRmState[].
Note that "data" array here is an array of type u8.

2. In function "update_network()" in staging/rtl8192e/rtllib_rx.c:
memcpy(dst->CcxRmState, src->CcxRmState, 2);

Here again, only 2 bytes are copied from the source state to
destination state.

There are no instances of "CcxRmState" requiring u16 data type.
Here is the output of "grep -IRn 'CcxRmState'" on the rtl8192e/
directory for reviewing:

rtllib_rx.c:1970:			memcpy(network->CcxRmState, &info_element->data[4], 2);
rtllib_rx.c:1971:			if (network->CcxRmState[0] != 0)
rtllib_rx.c:1975:			network->MBssidMask = network->CcxRmState[1] & 0x07;
rtllib_rx.c:2520:	memcpy(dst->CcxRmState, src->CcxRmState, 2);
rtllib.h:1108:	u8	CcxRmState[2];

//Note: The last line of output is my commit to this patch (u8 instead
of u16).

Signed-off-by: Atul Gopinathan <atulgopinathan@gmail.com>
---
 drivers/staging/rtl8192e/rtllib.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/rtl8192e/rtllib.h b/drivers/staging/rtl8192e/rtllib.h
index b84f00b8d18b..4cabaf21c1ca 100644
--- a/drivers/staging/rtl8192e/rtllib.h
+++ b/drivers/staging/rtl8192e/rtllib.h
@@ -1101,15 +1101,15 @@ struct rtllib_network {
 	u8 hidden_ssid[IW_ESSID_MAX_SIZE + 1];
 	u8 hidden_ssid_len;
 	struct rtllib_qos_data qos_data;
 
 	bool	bWithAironetIE;
 	bool	bCkipSupported;
 	bool	bCcxRmEnable;
-	u16	CcxRmState[2];
+	u8	CcxRmState[2];
 	bool	bMBssidValid;
 	u8	MBssidMask;
 	u8	MBssid[ETH_ALEN];
 	bool	bWithCcxVerNum;
 	u8	BssCcxVerNumber;
 	/* These are network statistics */
 	struct rtllib_rx_stats stats;
-- 
2.27.0

_______________________________________________
devel mailing list
devel@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel

  reply	other threads:[~2021-02-20 18:27 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-02-20 18:21 [PATCH 1/2] staging: rtl8192e: Pass array value to memcpy instead of struct pointer Atul Gopinathan
2021-02-20 18:21 ` Atul Gopinathan
2021-02-20 18:21 ` Atul Gopinathan [this message]
2021-02-20 18:21   ` [PATCH 2/2] staging: rtl8192e: Change state information from u16 to u8 Atul Gopinathan
2021-02-21 13:08   ` Greg KH
2021-02-21 13:08     ` Greg KH
2021-02-21 16:57     ` Atul Gopinathan
2021-02-21 16:57       ` Atul Gopinathan
2021-02-22 15:26       ` Greg KH
2021-02-22 15:26         ` Greg KH
2021-02-22 17:23         ` Atul Gopinathan
2021-02-22 17:23           ` Atul Gopinathan
2021-03-02 14:38           ` Greg KH
2021-03-02 14:38             ` Greg KH
2021-03-02 16:53             ` Atul Gopinathan
2021-03-02 16:53               ` Atul Gopinathan
2021-02-20 18:34 ` [PATCH 1/2] staging: rtl8192e: Pass array value to memcpy instead of struct pointer Gustavo A. R. Silva
2021-02-21  5:21   ` Atul Gopinathan
2021-02-21  5:21     ` Atul Gopinathan

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210220182154.9457-2-atulgopinathan@gmail.com \
    --to=atulgopinathan@gmail.com \
    --cc=devel@driverdev.osuosl.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=gustavo@embeddedor.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=tiwai@suse.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.