lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <1408403619.7460.1.camel@LTIRV-MCHAN1.corp.ad.broadcom.com>
Date:	Mon, 18 Aug 2014 16:13:39 -0700
From:	Michael Chan <mchan@...adcom.com>
To:	Andreea-Cristina Bernat <bernat.ada@...il.com>
CC:	<davem@...emloft.net>, <eddie.wai@...adcom.com>, <joe@...ches.com>,
	<mingo@...nel.org>, <peterz@...radead.org>,
	<netdev@...r.kernel.org>, <linux-kernel@...r.kernel.org>,
	<paulmck@...ux.vnet.ibm.com>
Subject: Re: [PATCH v2] cnic: Replace rcu_dereference() with
 rcu_access_pointer()

On Sun, 2014-08-17 at 13:12 +0300, Andreea-Cristina Bernat wrote: 
> 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: Andreea-Cristina Bernat <bernat.ada@...il.com>

Acked-by: Michael Chan <mchan@...adcom.com>

> ---
> 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 <davem@...emloft.net>
> 
>  drivers/net/ethernet/broadcom/cnic.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/net/ethernet/broadcom/cnic.c b/drivers/net/ethernet/broadcom/cnic.c
> index 8244e2b..dad9cb7 100644
> --- a/drivers/net/ethernet/broadcom/cnic.c
> +++ b/drivers/net/ethernet/broadcom/cnic.c
> @@ -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);


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ