From mboxrd@z Thu Jan 1 00:00:00 1970 From: Tejun Heo Subject: [PATCH 07/12] cgroup: cgroup->subsys[] should be cleared after the css is offlined Date: Mon, 14 Apr 2014 17:37:05 -0400 Message-ID: <1397511430-2673-8-git-send-email-tj@kernel.org> References: <1397511430-2673-1-git-send-email-tj@kernel.org> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=S9V0wEfDW7rtJMkhzBBBBWIQ8f5zi1Ty7QWsu4HLqKU=; b=n58mjungyym9I6NJVdtMdpJnfFF4IdosqFqg9+j6eUG9ziY0cN/82HU5lOouQmP4Gr 3biJ8DGf/brl+8iB9Zl+ifU3NAKeR4jYEgAuXBe4rQSgEqImfBGXWMGLBG1LaOo4b2qf aemGLrtUEPLVBiCmUmCHG7zY+XqAWjlNcwecuTg1isH2WV56pfggZWTjpPl1IgIGzjKJ RZJdajdWmhSvnWbDCfSjtt46KER6eTtBMJyIVTHOJMiLxqc0+xIRQVlJPAr2FCOUhteT yDEjXD3qjRDI3GoPp2kWEc1Q6ZjIr/uq2n9krKRuhkWE0TjqsPEca9qzLhdIzwasL9ri eYrw== In-Reply-To: <1397511430-2673-1-git-send-email-tj-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org> List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: containers-bounces-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org Errors-To: containers-bounces-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org To: lizefan-hv44wF8Li93QT0dZR+AlfA@public.gmane.org Cc: Tejun Heo , cgroups-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, containers-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org, linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org After a css finishes offlining, offline_css() mistakenly performs RCU_INIT_POINTER(css->cgroup->subsys[ss->id], css) which just sets the cgroup->subsys[] pointer to the current value. The intention was to clear it after offline is complete, not reassign the same value. Update it to assign NULL instead of the current value. This makes cgroup_css() to return NULL once offline is complete. All the existing users of the function either can handle NULL return already or guarantee that the css doesn't get offlined. While this is a bugfix, as css lifetime is currently tied to the cgroup it belongs to, this bug doesn't cause any actual problems. Signed-off-by: Tejun Heo Acked-by: Li Zefan --- kernel/cgroup.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/cgroup.c b/kernel/cgroup.c index 0318bfc..3de3951 100644 --- a/kernel/cgroup.c +++ b/kernel/cgroup.c @@ -3714,7 +3714,7 @@ static void offline_css(struct cgroup_subsys_state *css) css->flags &= ~CSS_ONLINE; css->cgroup->nr_css--; - RCU_INIT_POINTER(css->cgroup->subsys[ss->id], css); + RCU_INIT_POINTER(css->cgroup->subsys[ss->id], NULL); } /** -- 1.9.0