From patchwork Tue Oct 8 15:23:54 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Dumazet X-Patchwork-Id: 281496 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id A30052C00B9 for ; Wed, 9 Oct 2013 02:24:10 +1100 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753579Ab3JHPYI (ORCPT ); Tue, 8 Oct 2013 11:24:08 -0400 Received: from mail-yh0-f44.google.com ([209.85.213.44]:33480 "EHLO mail-yh0-f44.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751797Ab3JHPYI (ORCPT ); Tue, 8 Oct 2013 11:24:08 -0400 Received: by mail-yh0-f44.google.com with SMTP id f64so2119911yha.31 for ; Tue, 08 Oct 2013 08:24:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=message-id:subject:from:to:cc:date:in-reply-to:references :content-type:content-transfer-encoding:mime-version; bh=VkD4iWMgFipHQGVVEj0e8Zbo6D3nVyzTXlHXsoAxjNs=; b=D/jTUlzTldWRXGNt/h9jhxhziY9m44NEsu7jWsI0Oyt4NIsft+qV8Mu4dKn4eV00WG KygPRYwfm0RwiS9BM0ByTbZjPFpjGT+Ox/X2/9Dq7XSJyvq465VgC/gTwmRXE/xN9gOR p1D0XjVmNjmaa0H0Ph43OIb05l+MpFCeo8rA3sCQsNIpar0KuouQiU/tR8K5PFfDyF2n KFCTceXq+D9S8RRfjUpSnS9TYIK/uIDu9UrJk9yz5srneP3WJYUQBNfa98P2j5nGa2TV GFajk/tI/KpoB+yqz7hDlD0c32fvm1QWAKPNM+0YDHtf/yoQ8AbfFgClqpbPMY+egG/9 15Wg== X-Received: by 10.236.176.67 with SMTP id a43mr1789256yhm.68.1381245847384; Tue, 08 Oct 2013 08:24:07 -0700 (PDT) Received: from [172.26.49.234] ([172.26.49.234]) by mx.google.com with ESMTPSA id 9sm52828702yhd.19.1969.12.31.16.00.00 (version=SSLv3 cipher=RC4-SHA bits=128/128); Tue, 08 Oct 2013 08:24:06 -0700 (PDT) Message-ID: <1381245834.12191.37.camel@edumazet-glaptop.roam.corp.google.com> Subject: Re: [PATCH] nfnetlink: use rcu_assign_pointer in nfnetlink_subsys_unregister From: Eric Dumazet To: Gao feng Cc: netfilter-devel@vger.kernel.org Date: Tue, 08 Oct 2013 08:23:54 -0700 In-Reply-To: <1381226648-10959-1-git-send-email-gaofeng@cn.fujitsu.com> References: <1381226648-10959-1-git-send-email-gaofeng@cn.fujitsu.com> X-Mailer: Evolution 3.2.3-0ubuntu6 Mime-Version: 1.0 Sender: netfilter-devel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netfilter-devel@vger.kernel.org On Tue, 2013-10-08 at 18:04 +0800, Gao feng wrote: > Though I don't face an oops, but it is more safer to > set table's subsys through rcu_assign_pointer. > > Signed-off-by: Gao feng > --- > net/netfilter/nfnetlink.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/net/netfilter/nfnetlink.c b/net/netfilter/nfnetlink.c > index 572d87d..3cd2fe6 100644 > --- a/net/netfilter/nfnetlink.c > +++ b/net/netfilter/nfnetlink.c > @@ -78,7 +78,7 @@ EXPORT_SYMBOL_GPL(nfnetlink_subsys_register); > int nfnetlink_subsys_unregister(const struct nfnetlink_subsystem *n) > { > nfnl_lock(n->subsys_id); > - table[n->subsys_id].subsys = NULL; > + rcu_assign_pointer(table[n->subsys_id].subsys, NULL); > nfnl_unlock(n->subsys_id); > synchronize_rcu(); > return 0; Certainly not. Assigning a NULL pointer do not require rcu_assign_pointer() but this, if you want to be really really clean. --- To unsubscribe from this list: send the line "unsubscribe netfilter-devel" 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/netfilter/nfnetlink.c b/net/netfilter/nfnetlink.c index 572d87d..649958b 100644 --- a/net/netfilter/nfnetlink.c +++ b/net/netfilter/nfnetlink.c @@ -78,7 +78,7 @@ EXPORT_SYMBOL_GPL(nfnetlink_subsys_register); int nfnetlink_subsys_unregister(const struct nfnetlink_subsystem *n) { nfnl_lock(n->subsys_id); - table[n->subsys_id].subsys = NULL; + RCU_INIT_POINTER(table[n->subsys_id].subsys, NULL); nfnl_unlock(n->subsys_id); synchronize_rcu(); return 0;