Commit 270b4b31 authored by Andreea-Cristina Bernat's avatar Andreea-Cristina Bernat Committed by David S. Miller

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
  (...)
  ...+>)) {...}
)
Signed-off-by: default avatarAndreea-Cristina Bernat <bernat.ada@gmail.com>
Acked-by: default avatarMichael Chan <mchan@broadcom.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 1dced6a8
...@@ -383,7 +383,7 @@ static int cnic_iscsi_nl_msg_recv(struct cnic_dev *dev, u32 msg_type, ...@@ -383,7 +383,7 @@ static int cnic_iscsi_nl_msg_recv(struct cnic_dev *dev, u32 msg_type,
break; break;
rcu_read_lock(); rcu_read_lock();
if (!rcu_dereference(cp->ulp_ops[CNIC_ULP_L4])) { if (!rcu_access_pointer(cp->ulp_ops[CNIC_ULP_L4])) {
rc = -ENODEV; rc = -ENODEV;
rcu_read_unlock(); rcu_read_unlock();
break; break;
...@@ -527,7 +527,7 @@ int cnic_unregister_driver(int ulp_type) ...@@ -527,7 +527,7 @@ int cnic_unregister_driver(int ulp_type)
list_for_each_entry(dev, &cnic_dev_list, list) { list_for_each_entry(dev, &cnic_dev_list, list) {
struct cnic_local *cp = dev->cnic_priv; 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", pr_err("%s: Type %d still has devices registered\n",
__func__, ulp_type); __func__, ulp_type);
read_unlock(&cnic_dev_lock); read_unlock(&cnic_dev_lock);
...@@ -575,7 +575,7 @@ static int cnic_register_device(struct cnic_dev *dev, int ulp_type, ...@@ -575,7 +575,7 @@ static int cnic_register_device(struct cnic_dev *dev, int ulp_type,
mutex_unlock(&cnic_lock); mutex_unlock(&cnic_lock);
return -EAGAIN; 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", pr_err("%s: Type %d has already been registered to this device\n",
__func__, ulp_type); __func__, ulp_type);
mutex_unlock(&cnic_lock); mutex_unlock(&cnic_lock);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment