rtlwifi: rtl8192cu: Fix memset using sizeof(ptr) not sizeof(*ptr)
Subsystems (3)
PATCH 1/1 rtlwifi: rtl8192cu: Fix memset using sizeof(ptr) not sizeof(*ptr)
Found via coccinelle script
@@
type T;
T* ptr;
expression E1;
@@
* memset(E1, 0, sizeof(ptr));
--- drivers/net/wireless/rtlwifi/rtl8192cu/trx.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/net/wireless/rtlwifi/rtl8192cu/trx.c +1 -1
@@ -372,7 +372,7 @@ static void _rtl_rx_process(struct ieee80211_hw *hw, struct sk_buff *skb)__le16 fc;struct ieee80211_hdr *hdr; -memset (rx_status,0 ,sizeof (rx_status)); +memset (rx_status,0 ,sizeof (*rx_status)); rxdesc = skb->data; skb_len = skb->len; drvinfo_len = (GET_RX_DESC_DRVINFO_SIZE (rxdesc) *RTL_RX_DRV_INFO_UNIT );
Quoted 20 lines · Joe Perches
Found via coccinelle script
@@
type T;
T* ptr;
expression E1;
@@*
memset(E1, 0, sizeof(ptr));Signed-off-by Joe Perches<[email protected]>--- drivers/net/wireless/rtlwifi/rtl8192cu/trx.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)drivers/net/wireless/rtlwifi/rtl8192cu/trx.c +0
-0
drivers/net/wireless/rtlwifi/rtl8192cu/trx.c static void _rtl_rx_process(struct ieee80211_hw *hw, struct sk_buff *skb) · line 378
Quoted 8 lines
drivers/net/wireless/rtlwifi/rtl8192cu/trx.c +1
-1@@ -372,7 +372,7 @@ static void _rtl_rx_process(struct ieee80211_hw *hw, struct sk_buff *skb)__le16 fc;struct ieee80211_hdr *hdr; -memset (rx_status,0 ,sizeof (rx_status)); +memset (rx_status,0 ,sizeof (*rx_status)); rxdesc = skb->data; skb_len = skb->len; drvinfo_len = (GET_RX_DESC_DRVINFO_SIZE (rxdesc) *RTL_RX_DRV_INFO_UNIT );
ACK.
Larry
PATCH v2 1/1 rtlwifi: rtl8192cu: Fix memset/memcpy using sizeof(ptr) not sizeof(*ptr)
Quoted 13 lines · Larry Finger
Quoted 12 lines · Joe Perches
Found via coccinelle script
@@
type T;
T* ptr;
expression E1;
@@
*memset(E1, 0, sizeof(ptr));Signed-off-by Joe Perches<[email protected]>--- drivers/net/wireless/rtlwifi/rtl8192cu/trx.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
Quoted 2 lines
drivers/net/wireless/rtlwifi/rtl8192cu/trx.c static void _rtl_rx_process(struct ieee80211_hw *hw, struct sk_buff *skb)
Quoted 2 lines
drivers/net/wireless/rtlwifi/rtl8192cu/trx.c +0
-0@@ -372,7 +372,7 @@ static void _rtl_rx_process(struct ieee80211_hw *hw, struct sk_buff *skb)
[]
Quoted 2 lines
drivers/net/wireless/rtlwifi/rtl8192cu/trx.c static void _rtl_rx_process(struct ieee80211_hw *hw, struct sk_buff *skb) · line 372
Quoted 1 line
drivers/net/wireless/rtlwifi/rtl8192cu/trx.c +1
-0+memset (rx_status,0 ,sizeof (*rx_status));ACK.
Hey Larry.
If this is correct, then probably the memcpy at the end of the routine needs conversion too.
---
drivers/net/wireless/rtlwifi/rtl8192cu/trx.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-)
drivers/net/wireless/rtlwifi/rtl8192cu/trx.c +2 -2
@@ -372,7 +372,7 @@ static void _rtl_rx_process(struct ieee80211_hw *hw, struct sk_buff *skb)__le16 fc;struct ieee80211_hdr *hdr; -memset (rx_status,0 ,sizeof (rx_status)); +memset (rx_status,0 ,sizeof (*rx_status)); rxdesc = skb->data; skb_len = skb->len; drvinfo_len = (GET_RX_DESC_DRVINFO_SIZE (rxdesc) *RTL_RX_DRV_INFO_UNIT );
@@ -434,7 +434,7 @@ static void _rtl_rx_process(struct ieee80211_hw *hw, struct sk_buff *skb)"0x%02X\n" , fc, (u32 )hdr->addr1[0 ], (u32 )hdr->addr1[1 ], (u32 )hdr->addr1[2 ], (u32 )hdr->addr1[3 ], (u32 )hdr->addr1[4 ], (u32)hdr->addr1[5])); -memcpy (IEEE80211_SKB_RXCB (skb), &rx_status,sizeof (rx_status)); +memcpy (IEEE80211_SKB_RXCB (skb), rx_status,sizeof (*rx_status));ieee80211_rx_irqsafe (hw, skb); }
Re: [PATCH V2] rtlwifi: rtl8192cu: Fix memset/memcpy using sizeof(ptr) not sizeof(*ptr)
Quoted 44 lines · Joe Perches
Quoted 13 lines · Larry Finger
Quoted 12 lines · Joe Perches
Found via coccinelle script
@@
type T;
T* ptr;
expression E1;
@@
*memset(E1, 0, sizeof(ptr));Signed-off-by Joe Perches<[email protected]>--- drivers/net/wireless/rtlwifi/rtl8192cu/trx.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)Quoted 2 lines
drivers/net/wireless/rtlwifi/rtl8192cu/trx.c static void _rtl_rx_process(struct ieee80211_hw *hw, struct sk_buff *skb)
Quoted 2 lines
drivers/net/wireless/rtlwifi/rtl8192cu/trx.c +0
-0@@ -372,7 +372,7 @@ static void _rtl_rx_process(struct ieee80211_hw *hw, struct sk_buff *skb)[]
Quoted 2 lines
drivers/net/wireless/rtlwifi/rtl8192cu/trx.c static void _rtl_rx_process(struct ieee80211_hw *hw, struct sk_buff *skb) · line 375
Quoted 1 line
drivers/net/wireless/rtlwifi/rtl8192cu/trx.c +1
-0+memset (rx_status,0 ,sizeof (*rx_status));ACK.
Hey Larry.
If this is correct, then probably the memcpy at the end of the routine needs conversion too.
---
drivers/net/wireless/rtlwifi/rtl8192cu/trx.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-)drivers/net/wireless/rtlwifi/rtl8192cu/trx.c +1
-1@@ -372,7 +372,7 @@ static void _rtl_rx_process(struct ieee80211_hw *hw, struct sk_buff *skb)__le16 fc;struct ieee80211_hdr *hdr; -memset (rx_status,0 ,sizeof (rx_status)); +memset (rx_status,0 ,sizeof (*rx_status)); rxdesc = skb->data; skb_len = skb->len; drvinfo_len = (GET_RX_DESC_DRVINFO_SIZE (rxdesc) *RTL_RX_DRV_INFO_UNIT );
drivers/net/wireless/rtlwifi/rtl8192cu/trx.c static void _rtl_rx_process(struct ieee80211_hw *hw, struct sk_buff *skb) · line 439
Quoted 7 lines
drivers/net/wireless/rtlwifi/rtl8192cu/trx.c +1
-1@@ -434,7 +434,7 @@ static void _rtl_rx_process(struct ieee80211_hw *hw, struct sk_buff *skb)"0x%02X\n" , fc, (u32 )hdr->addr1[0 ], (u32 )hdr->addr1[1 ], (u32 )hdr->addr1[2 ], (u32 )hdr->addr1[3 ], (u32 )hdr->addr1[4 ], (u32)hdr->addr1[5])); -memcpy (IEEE80211_SKB_RXCB (skb),&rx_status,sizeof (rx_status)); +memcpy (IEEE80211_SKB_RXCB (skb), rx_status,sizeof (*rx_status));ieee80211_rx_irqsafe (hw, skb); }
Yes it does. After you posted V1 of the patch, I reviewed all the sizeof() calls in the rtlwifi tree and found the second one at line 437.
ACK for V2 once the commit message is fixed.
Larry
PATCH v3 1/1 rtlwifi: rtl8192cu: Fix memset/memcpy using sizeof(ptr) not sizeof(*ptr)
Found via coccinelle script
@@
type T;
T* ptr;
expression E1;
@@
* memset(E1, 0, sizeof(ptr));
---
drivers/net/wireless/rtlwifi/rtl8192cu/trx.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-)
drivers/net/wireless/rtlwifi/rtl8192cu/trx.c +2 -2
@@ -372,7 +372,7 @@ static void _rtl_rx_process(struct ieee80211_hw *hw, struct sk_buff *skb)__le16 fc;struct ieee80211_hdr *hdr; -memset (rx_status,0 ,sizeof (rx_status)); +memset (rx_status,0 ,sizeof (*rx_status)); rxdesc = skb->data; skb_len = skb->len; drvinfo_len = (GET_RX_DESC_DRVINFO_SIZE (rxdesc) *RTL_RX_DRV_INFO_UNIT );
@@ -434,7 +434,7 @@ static void _rtl_rx_process(struct ieee80211_hw *hw, struct sk_buff *skb)"0x%02X\n" , fc, (u32 )hdr->addr1[0 ], (u32 )hdr->addr1[1 ], (u32 )hdr->addr1[2 ], (u32 )hdr->addr1[3 ], (u32 )hdr->addr1[4 ], (u32)hdr->addr1[5])); -memcpy (IEEE80211_SKB_RXCB (skb), &rx_status,sizeof (rx_status)); +memcpy (IEEE80211_SKB_RXCB (skb), rx_status,sizeof (*rx_status));ieee80211_rx_irqsafe (hw, skb); }