Received: by 10.223.176.46 with SMTP id f43csp2916727wra; Mon, 22 Jan 2018 05:40:06 -0800 (PST) X-Google-Smtp-Source: AH8x227tQaIJdAf4dKXWAR61lK2IFJav/0GiWLmBnYhr64P4nJQ7EFnaF6erG6/hyey3MUtpZMNr X-Received: by 10.98.130.142 with SMTP id w136mr6336932pfd.236.1516628406781; Mon, 22 Jan 2018 05:40:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516628406; cv=none; d=google.com; s=arc-20160816; b=PPvOrW2pVJwExEFOtQCBx/2IMslCBlHmTYPlmxkkXUaHLaa9/MbDhxSgskTNdqKK5y fZUdDRAwRL5phcojIZLWfa/+Ce1zFPWJ42I7qdiHz99TroEv9a0/SPp/cgOl+HtG0wH6 X7XietjDpxDuaggERQPnKWqVDNB35syhXQ0Cd/xYHufX/2OeRX5VoXS9ek5j89MHDQ+H 52x6unZ/uwBwH7xe5eb6ORA1QzIocFWk6LNDaC/aEYkRR8ThjD77ySsBGNe/YN2ssYhY Ul9ZE/os4m3DLqLi4aK5w5Z26SYA0O1AtcJkNQxY+oCCDQAjj8+E88eCLzzKZ9WB0kw1 fNng== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=gpj5QlmAUYv8A3bgFc2gDVdWBKN4KSKNN4wPVRw840c=; b=Ndxqw8NRlUfN3JiQhVGnegRyE+GBRF94Mhqth9T9Y3nAHGQY7KP9o78o+VjTYC1ZzU bMyelJ/khh/EIFaTDzS4RK7xJNtpfcUXgv35KxZ6mRcoKDejOegNcOuyyWa274qsAzBl 8HmxDh9mJtUwCTiG2aUN2fXHOtTjIw7i2dMJ+VcfgToMkt15eKkX1WJxkvyM03Chkm1M ah+xhBTzmWlGby8UHQqP5I+h7cjL73uiv6MK0CkllStuZmymIA8znZLe809d1qBPLlcj YdKCZg8qwWfygpTiaQAY/hYmtH4LK240D8OJ4F0spO3ZHxuukTcpPpE4xY29SP+Kx5AN KmTw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@me.com header.s=04042017 header.b=py1lYxGw; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=me.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v10-v6si3469872plo.820.2018.01.22.05.39.52; Mon, 22 Jan 2018 05:40:06 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@me.com header.s=04042017 header.b=py1lYxGw; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=me.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751242AbeAVNjT (ORCPT + 99 others); Mon, 22 Jan 2018 08:39:19 -0500 Received: from pv33p00im-asmtp002.me.com ([17.142.194.251]:45069 "EHLO pv33p00im-asmtp002.me.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750955AbeAVNjS (ORCPT ); Mon, 22 Jan 2018 08:39:18 -0500 Received: from process-dkim-sign-daemon.pv33p00im-asmtp002.me.com by pv33p00im-asmtp002.me.com (Oracle Communications Messaging Server 8.0.1.2.20170607 64bit (built Jun 7 2017)) id <0P2Y00000LJCL300@pv33p00im-asmtp002.me.com> for linux-kernel@vger.kernel.org; Mon, 22 Jan 2018 13:39:05 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=me.com; s=04042017; t=1516628345; bh=gpj5QlmAUYv8A3bgFc2gDVdWBKN4KSKNN4wPVRw840c=; h=From:To:Subject:Date:Message-id; b=py1lYxGwwmgjqak72bZAdq9n0dwT7R6oN2AT66Bfy6K5LotlrG7nNIqMSGozqXXgh mfBR/1aT7FUTiDvgqzp6JhxeGtsRT1dxonms6EhL+WXhPRbMS0l6/OOFnLhwxWXkgT 2+VvtDmBg3TcPF929ALdJj6xR4BN8Tq2vswqlhkD0LDexFZKBU/uF8dSvznHiFwsU2 bPC6oN+YG6vwUdYXePUWGpN69ZdtbDCcWRqzqG+iJXxgXQGbJAN1SrUAxTBcTkOxBt 61NEQhQMNgHMXn0LW2yifUGOrU27VafDvKhs1OvAxyb0p9xowJoTz8W9TCyi8WsaZM hPt5kkk3kI0cA== Received: from icloud.com ([127.0.0.1]) by pv33p00im-asmtp002.me.com (Oracle Communications Messaging Server 8.0.1.2.20170607 64bit (built Jun 7 2017)) with ESMTPSA id <0P2Y009G4LWS1O20@pv33p00im-asmtp002.me.com>; Mon, 22 Jan 2018 13:39:02 +0000 (GMT) X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:,, definitions=2018-01-22_05:,, signatures=0 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 clxscore=1011 suspectscore=0 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1707230000 definitions=main-1801220196 From: Xiongwei Song To: tj@kernel.org, guro@fb.com, longman@redhat.com, davem@davemloft.net, akpm@linux-foundation.org Cc: linux-kernel@vger.kernel.org, sxwjean@gmail.com Subject: [PATCH] cgroup: remove incorrect check on the return value of css_alloc Date: Mon, 22 Jan 2018 21:38:51 +0800 Message-id: <20180122133851.19772-1-sxwjean@me.com> X-Mailer: git-send-email 2.15.1 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The function css_alloc never return NULL, it may return normal pointer or error codes that made by ERR_PTR, so !css is always false, we need use IS_ERR to check it, and if this is true, we should use ERR_CAST handle it. Signed-off-by: Xiongwei Song --- kernel/cgroup/cgroup.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/kernel/cgroup/cgroup.c b/kernel/cgroup/cgroup.c index adac5b91d2b8..a442fd9ad744 100644 --- a/kernel/cgroup/cgroup.c +++ b/kernel/cgroup/cgroup.c @@ -4728,10 +4728,8 @@ static struct cgroup_subsys_state *css_create(struct cgroup *cgrp, lockdep_assert_held(&cgroup_mutex); css = ss->css_alloc(parent_css); - if (!css) - css = ERR_PTR(-ENOMEM); if (IS_ERR(css)) - return css; + return ERR_CAST(css); init_and_link_css(css, ss, cgrp); -- 2.15.1