From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755026AbcEZTmR (ORCPT ); Thu, 26 May 2016 15:42:17 -0400 Received: from mail-yw0-f194.google.com ([209.85.161.194]:34645 "EHLO mail-yw0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754298AbcEZTmP (ORCPT ); Thu, 26 May 2016 15:42:15 -0400 Date: Thu, 26 May 2016 15:42:13 -0400 From: Tejun Heo To: Wenwei Tao Cc: lizefan@huawei.com, hannes@cmpxchg.org, ww.tao0320@gmail.com, cgroups@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH cgroup/for-4.7-fixes] cgroup: set css->id to -1 during init Message-ID: <20160526194213.GD23194@mtj.duckdns.org> References: <1463151560-5224-1-git-send-email-wwtao0320@163.com> <20160526191358.GB23194@mtj.duckdns.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20160526191358.GB23194@mtj.duckdns.org> User-Agent: Mutt/1.6.1 (2016-04-27) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hello, A follow-up patch. Will queue in cgroup/for-4.7-fixes. Thanks. ------ 8< ------ If percpu_ref initialization fails during css_create(), the free path can end up trying to free css->id of zero. As ID 0 is unused, it doesn't cause a critical breakage but it does trigger a warning message. Fix it by setting css->id to -1 from init_and_link_css(). Signed-off-by: Tejun Heo Cc: Wenwei Tao Fixes: 01e586598b22 ("cgroup: release css->id after css_free") Cc: stable@vger.kernel.org # v4.0+ --- kernel/cgroup.c | 1 + 1 file changed, 1 insertion(+) diff --git a/kernel/cgroup.c b/kernel/cgroup.c index 789b84f..688eb0c 100644 --- a/kernel/cgroup.c +++ b/kernel/cgroup.c @@ -5063,6 +5063,7 @@ static void init_and_link_css(struct cgroup_subsys_state *css, memset(css, 0, sizeof(*css)); css->cgroup = cgrp; css->ss = ss; + css->id = -1; INIT_LIST_HEAD(&css->sibling); INIT_LIST_HEAD(&css->children); css->serial_nr = css_serial_nr_next++;