cnic: Replace rcu_dereference() with rcu_access_pointer()
Subsystems (2)
PATCH v2 1/1 cnic: Replace rcu_dereference() with rcu_access_pointer()
The "rcu_dereference()" calls are used directly in conditions. Since their return values are never dereferenced it is recommended to use "rcu_access_pointer()" instead of "rcu_dereference()". Therefore, this patch makes the replacements.
The following Coccinelle semantic patch was used:
@@
@@
(
if(
(<+...
- rcu_dereference
+ rcu_access_pointer
(...)
...+>)) {...}
|
while(
(<+...
- rcu_dereference
+ rcu_access_pointer
(...)
...+>)) {...}
)
---
v2: Modified subject line from
"rcu: Replace rcu_dereference() with rcu_access_pointer()" to
"cnic: Replace rcu_dereference() with rcu_access_pointer()", noted by David Miller <[email protected]>
drivers/net/ethernet/broadcom/cnic.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/net/ethernet/broadcom/cnic.c +3 -3
@@ -381,7 +381,7 @@ static int cnic_iscsi_nl_msg_recv(struct cnic_dev *dev, u32 msg_type,break ;rcu_read_lock (); -if (!rcu_dereference (cp->ulp_ops[CNIC_ULP_L4 ])) { +if (!rcu_access_pointer (cp->ulp_ops[CNIC_ULP_L4 ])) { rc = -ENODEV ;rcu_read_unlock ();break ;
@@ -525,7 +525,7 @@ int cnic_unregister_driver(int ulp_type)list_for_each_entry (dev, &cnic_dev_list, list) {struct cnic_local *cp = dev->cnic_priv; -if (rcu_dereference (cp->ulp_ops[ulp_type])) { +if (rcu_access_pointer (cp->ulp_ops[ulp_type])) {pr_err ("%s: Type %d still has devices registered\n" , __func__, ulp_type);read_unlock (&cnic_dev_lock);
@@ -573,7 +573,7 @@ static int cnic_register_device(struct cnic_dev *dev, int ulp_type,mutex_unlock (&cnic_lock);return -EAGAIN ; } -if (rcu_dereference (cp->ulp_ops[ulp_type])) { +if (rcu_access_pointer (cp->ulp_ops[ulp_type])) {pr_err ("%s: Type %d has already been registered to this device\n" , __func__, ulp_type);mutex_unlock (&cnic_lock);
Signature · 1 line
1.9.1
Quoted 25 lines · Andreea-Cristina Bernat
The "
rcu_dereference()" calls are used directly in conditions. Since their return values are never dereferenced it is recommended to use "rcu_access_pointer()" instead of "rcu_dereference()". Therefore, this patch makes the replacements.The following Coccinelle semantic patch was used:
@@
@@(
if(
(<+...
-rcu_dereference
+rcu_access_pointer
(...)
...+>)) {...}
|
while(
(<+...
-rcu_dereference
+rcu_access_pointer
(...)
...+>)) {...}
)
Quoted 1 line
Signed-off-by Andreea-Cristina Bernat <[email protected]>
Quoted 41 lines
---
v2: Modified subject line from
"rcu: Replacercu_dereference()withrcu_access_pointer()" to
"cnic: Replacercu_dereference()withrcu_access_pointer()", noted by David Miller <[email protected]>drivers/net/ethernet/broadcom/cnic.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)drivers/net/ethernet/broadcom/cnic.c +3
-3@@ -381,7 +381,7 @@ static int cnic_iscsi_nl_msg_recv(struct cnic_dev *dev, u32 msg_type,break ;rcu_read_lock (); -if (!rcu_dereference (cp->ulp_ops[CNIC_ULP_L4 ])) { +if (!rcu_access_pointer (cp->ulp_ops[CNIC_ULP_L4 ])) { rc = -ENODEV ;rcu_read_unlock ();break ;@@ -525,7 +525,7 @@ int cnic_unregister_driver(int ulp_type)list_for_each_entry (dev, &cnic_dev_list, list) {struct cnic_local *cp = dev->cnic_priv; -if (rcu_dereference (cp->ulp_ops[ulp_type])) { +if (rcu_access_pointer (cp->ulp_ops[ulp_type])) {pr_err ("%s: Type %d still has devices registered\n" , __func__, ulp_type);read_unlock (&cnic_dev_lock);@@ -573,7 +573,7 @@ static int cnic_register_device(struct cnic_dev *dev, int ulp_type,mutex_unlock (&cnic_lock);return -EAGAIN ; } -if (rcu_dereference (cp->ulp_ops[ulp_type])) { +if (rcu_access_pointer (cp->ulp_ops[ulp_type])) {pr_err ("%s: Type %d has already been registered to this device\n" , __func__, ulp_type);mutex_unlock (&cnic_lock);
From: Andreea-Cristina Bernat <[email protected]>
Date: Sun, 17 Aug 2014 13:12:09 +0300
Quoted 4 lines
The "
rcu_dereference()" calls are used directly in conditions. Since their return values are never dereferenced it is recommended to use "rcu_access_pointer()" instead of "rcu_dereference()". Therefore, this patch makes the replacements.
...
Quoted 1 line
Signed-off-by Andreea-Cristina Bernat <[email protected]>
Applied.