Skip to contentSkip to conversation

rtl8188eu: rtw_xmit: Replace rcu_dereference() with rcu_access_pointer()

PATCH In review Andreea-Cristina Bernat 2 participants 3 messages Sep 4, 2014 – Sep 9, 2014 Staging

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 rtl8188eu: rtw_xmit: Replace rcu_dereference() with rcu_access_pointer()

The "br_port" local variables obtained through the rcu_dereference() calls are not dereferenced in the rest of their function.
Therefore, it is recommended to use rcu_access_pointer() instead of rcu_dereference().
This patch makes the replacements.

The first step to detect this was made with the following Coccinelle semantic patch:
@@
identifier p;
@@

* p = rcu_dereference(...)
... when any

    when != p

(
* if( (<+...p...+>) ) { ... }
|
* while( (<+...p...+>) ) { ... }
)
... when != p

After the analysis of the output, the change was made manually.

---
 drivers/staging/rtl8188eu/core/rtw_xmit.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/staging/rtl8188eu/core/rtw_xmit.c +2 -2
index 1413ec8..93228dc 100644
@@ -1684,7 +1684,7 @@ static int rtw_br_client_tx(struct adapter *padapter, struct sk_buff **pskb)
 	void *br_port = NULL;
 
 	rcu_read_lock();
-	br_port = rcu_dereference(padapter->pnetdev->rx_handler_data);
+	br_port = rcu_access_pointer(padapter->pnetdev->rx_handler_data);
 	rcu_read_unlock();
 	spin_lock_bh(&padapter->br_ext_lock);
 	if (!(skb->data[0] & 1) && br_port &&
@@ -1868,7 +1868,7 @@ s32 rtw_xmit(struct adapter *padapter, struct sk_buff **ppkt)
 	}
 
 	rcu_read_lock();
-	br_port = rcu_dereference(padapter->pnetdev->rx_handler_data);
+	br_port = rcu_access_pointer(padapter->pnetdev->rx_handler_data);
 	rcu_read_unlock();
 
 	if (br_port && check_fwstate(pmlmepriv, WIFI_STATION_STATE|WIFI_ADHOC_STATE)) {
Signature · 1 line
1.9.1
maintainer
#1 lore raw
Quoted 43 lines · Andreea-Cristina Bernat

The "br_port" local variables obtained through the rcu_dereference() calls are not dereferenced in the rest of their function.
Therefore, it is recommended to use rcu_access_pointer() instead of rcu_dereference().
This patch makes the replacements.

The first step to detect this was made with the following Coccinelle semantic patch:
@@
identifier p;
@@

* p = rcu_dereference(...)
... when any

    when != p

(
* if( (<+...p...+>) ) { ... }
|
* while( (<+...p...+>) ) { ... }
)
... when != p

After the analysis of the output, the change was made manually.

---
 drivers/staging/rtl8188eu/core/rtw_xmit.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/staging/rtl8188eu/core/rtw_xmit.c +1 -1
index 1413ec8..93228dc 100644
@@ -1684,7 +1684,7 @@ static int rtw_br_client_tx(struct adapter *padapter, struct sk_buff **pskb)
 	void *br_port = NULL;
 
 	rcu_read_lock();
-	br_port = rcu_dereference(padapter->pnetdev->rx_handler_data);
+	br_port = rcu_access_pointer(padapter->pnetdev->rx_handler_data);
 	rcu_read_unlock();
 	spin_lock_bh(&padapter->br_ext_lock);
 	if (!(skb->data[0] & 1) && br_port &&

drivers/staging/rtl8188eu/core/rtw_xmit.c s32 rtw_xmit(struct adapter *padapter, struct sk_buff **ppkt) · line 1874

Quoted 8 lines
drivers/staging/rtl8188eu/core/rtw_xmit.c +1 -1
@@ -1868,7 +1868,7 @@ s32 rtw_xmit(struct adapter *padapter, struct sk_buff **ppkt)
 	}
 
 	rcu_read_lock();
-	br_port = rcu_dereference(padapter->pnetdev->rx_handler_data);
+	br_port = rcu_access_pointer(padapter->pnetdev->rx_handler_data);
 	rcu_read_unlock();
 
 	if (br_port && check_fwstate(pmlmepriv, WIFI_STATION_STATE|WIFI_ADHOC_STATE)) {

This patch doesn't apply at all to my staging-next branch of the staging.git tree on git.kernel.org :(

#2 lore raw

The rcu_dereference() calls are no longer there.
They were removed.

Sorry,
Andreea

2014-09-08 23:48 GMT+03:00 Greg KH <[email protected]>:

Quoted 56 lines · Andreea-Cristina Bernat
Quoted 43 lines

The "br_port" local variables obtained through the rcu_dereference() calls are not dereferenced in the rest of their function.
Therefore, it is recommended to use rcu_access_pointer() instead of rcu_dereference().
This patch makes the replacements.

The first step to detect this was made with the following Coccinelle semantic patch:
@@
identifier p;
@@

* p = rcu_dereference(...)
... when any

    when != p

(
* if( (<+...p...+>) ) { ... }
|
* while( (<+...p...+>) ) { ... }
)
... when != p

After the analysis of the output, the change was made manually.

---
 drivers/staging/rtl8188eu/core/rtw_xmit.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/staging/rtl8188eu/core/rtw_xmit.c +1 -1
index 1413ec8..93228dc 100644
@@ -1684,7 +1684,7 @@ static int rtw_br_client_tx(struct adapter *padapter, struct sk_buff **pskb)
      void *br_port = NULL;
 
      rcu_read_lock();
-     br_port = rcu_dereference(padapter->pnetdev->rx_handler_data);
+     br_port = rcu_access_pointer(padapter->pnetdev->rx_handler_data);
      rcu_read_unlock();
      spin_lock_bh(&padapter->br_ext_lock);
      if (!(skb->data[0] & 1) && br_port &&

drivers/staging/rtl8188eu/core/rtw_xmit.c s32 rtw_xmit(struct adapter *padapter, struct sk_buff **ppkt) · line 1874

Quoted 8 lines
drivers/staging/rtl8188eu/core/rtw_xmit.c +1 -1
@@ -1868,7 +1868,7 @@ s32 rtw_xmit(struct adapter *padapter, struct sk_buff **ppkt)
      }
 
      rcu_read_lock();
-     br_port = rcu_dereference(padapter->pnetdev->rx_handler_data);
+     br_port = rcu_access_pointer(padapter->pnetdev->rx_handler_data);
      rcu_read_unlock();
 
      if (br_port && check_fwstate(pmlmepriv, WIFI_STATION_STATE|WIFI_ADHOC_STATE)) {

This patch doesn't apply at all to my staging-next branch of the staging.git tree on git.kernel.org :(