From patchwork Wed Dec 14 06:29:43 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Carpenter X-Patchwork-Id: 131313 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3E8701007D6 for ; Wed, 14 Dec 2011 17:30:38 +1100 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752045Ab1LNGaK (ORCPT ); Wed, 14 Dec 2011 01:30:10 -0500 Received: from rcsinet15.oracle.com ([148.87.113.117]:16423 "EHLO rcsinet15.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751119Ab1LNGaH (ORCPT ); Wed, 14 Dec 2011 01:30:07 -0500 Received: from ucsinet21.oracle.com (ucsinet21.oracle.com [156.151.31.93]) by rcsinet15.oracle.com (Switch-3.4.4/Switch-3.4.4) with ESMTP id pBE6TrHF002070 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Wed, 14 Dec 2011 06:29:58 GMT Received: from acsmt356.oracle.com (acsmt356.oracle.com [141.146.40.156]) by ucsinet21.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id pBE6Tp8B004425 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Wed, 14 Dec 2011 06:29:52 GMT Received: from abhmt104.oracle.com (abhmt104.oracle.com [141.146.116.56]) by acsmt356.oracle.com (8.12.11.20060308/8.12.11) with ESMTP id pBE6TjoD010765; Wed, 14 Dec 2011 00:29:45 -0600 Received: from elgon.mountain (/41.139.221.94) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Tue, 13 Dec 2011 22:29:45 -0800 Date: Wed, 14 Dec 2011 09:29:43 +0300 From: Dan Carpenter To: Patrick McHardy Cc: "David S. Miller" , netdev@vger.kernel.org, kernel-janitors@vger.kernel.org, Jiri Pirko Subject: [patch] vlan: add rtnl_dereference() annotations Message-ID: <20111214062943.GD7499@elgon.mountain> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) X-Source-IP: ucsinet21.oracle.com [156.151.31.93] X-CT-RefId: str=0001.0A090207.4EE84267.0084,ss=1,re=0.000,fgs=0 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org The original code generates a Sparse warning: net/8021q/vlan_core.c:336:9: error: incompatible types in comparison expression (different address spaces) It's ok to dereference __rcu pointers here because we are holding the RTNL lock. I've added some calls to rtnl_dereference() to silence the warning. Signed-off-by: Dan Carpenter Acked-by: Eric Dumazet Acked-by: Jiri Pirko --- I haven't tested this, and I'm not super familiar with this code. Please review it carefully. -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/net/8021q/vlan_core.c b/net/8021q/vlan_core.c index 1414c93..4d39d80 100644 --- a/net/8021q/vlan_core.c +++ b/net/8021q/vlan_core.c @@ -326,14 +326,16 @@ int vlan_vids_add_by_dev(struct net_device *dev, const struct net_device *by_dev) { struct vlan_vid_info *vid_info; + struct vlan_info *vlan_info; int err; ASSERT_RTNL(); - if (!by_dev->vlan_info) + vlan_info = rtnl_dereference(by_dev->vlan_info); + if (!vlan_info) return 0; - list_for_each_entry(vid_info, &by_dev->vlan_info->vid_list, list) { + list_for_each_entry(vid_info, &vlan_info->vid_list, list) { err = vlan_vid_add(dev, vid_info->vid); if (err) goto unwind; @@ -342,7 +344,7 @@ int vlan_vids_add_by_dev(struct net_device *dev, unwind: list_for_each_entry_continue_reverse(vid_info, - &by_dev->vlan_info->vid_list, + &vlan_info->vid_list, list) { vlan_vid_del(dev, vid_info->vid); } @@ -355,13 +357,15 @@ void vlan_vids_del_by_dev(struct net_device *dev, const struct net_device *by_dev) { struct vlan_vid_info *vid_info; + struct vlan_info *vlan_info; ASSERT_RTNL(); - if (!by_dev->vlan_info) + vlan_info = rtnl_dereference(by_dev->vlan_info); + if (!vlan_info) return; - list_for_each_entry(vid_info, &by_dev->vlan_info->vid_list, list) + list_for_each_entry(vid_info, &vlan_info->vid_list, list) vlan_vid_del(dev, vid_info->vid); } EXPORT_SYMBOL(vlan_vids_del_by_dev);