From patchwork Fri Nov 4 18:20:48 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Waiman Long X-Patchwork-Id: 15743 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp567184wru; Fri, 4 Nov 2022 11:25:38 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7yiF+HHAis7olsthATN9rcY6m53tmHmqVeCzH91jXFFMWfpC2+2Pn3wehrZT5TPlugw2A+ X-Received: by 2002:a05:6402:c07:b0:461:87ab:78aa with SMTP id co7-20020a0564020c0700b0046187ab78aamr37602158edb.258.1667586338637; Fri, 04 Nov 2022 11:25:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1667586338; cv=none; d=google.com; s=arc-20160816; b=fA21aQC07ImpMoK9eFoTX5VzJfeqQF1AJ+cqkaLeadui1m/vf9kYpeu17gwLkjZIZQ YUVGO3ujeo7Nl31O8qLvHZ3NCLFJhnGg3PGFTDjBEyNirXcS21wSStO4KVNM8wfKKuOt FO2TF8plYfeXMRP1pPqYhyV8uUdSlicbpuZCrBpHu/p5JoKq6+z/ErC4qJc47vEbqVap ewos+/2JsnDddeFtBSdv3m6h6+46j/gzYgJi1VkcFFXEzMdUMSxx82JlYSK0I2wZEIae tVjrDGNXdeq21R1L20ffSLpQVSvzf659pUeKkxn+4r7WMjUGLLt+K9qugE8jkk6leNJE FBJQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=fsF/w+s1hazC7fbvdAgtahejdx2Z7prb6bJ8RwO66qE=; b=nATPpRKMdgxad2VjPu3sR/9FLuFzt5Pi0TOU6mIjysf92eK78rURNHF2W4LmDQMEF1 bArDJ5ZgHA/ZiBdJZFip7HJt3NFaP2uof3k4g9KiCFFxW2DAVgrLiBH94ixyQ9L0VpGC H9H43XayQ4oE0WdPq5Pg7ed7KeCYY33Ju/qjpwB+sBEIQlqZu2woR06FzrIPxds2DkY/ ROYcF0wFteAvAfvBXQE7OFKzlE8uje5JabnQjCclgRav+P+hgDz6ROffZgJaGuCANp8P z9e132KZqdetyHj7gzfCZGWJSzxjZilPpK6ei/cxsHpqOZ7PH9Yo7AmTAy2YcIEuyFRC p9/Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=K464wRwu; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id g11-20020a50ec0b000000b0045bc92ef2c0si208727edr.195.2022.11.04.11.25.15; Fri, 04 Nov 2022 11:25:38 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=K464wRwu; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230509AbiKDSVy (ORCPT + 99 others); Fri, 4 Nov 2022 14:21:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41014 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231543AbiKDSVw (ORCPT ); Fri, 4 Nov 2022 14:21:52 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AFE9F2B8 for ; Fri, 4 Nov 2022 11:21:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1667586060; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=fsF/w+s1hazC7fbvdAgtahejdx2Z7prb6bJ8RwO66qE=; b=K464wRwuAxU9qUuw+GgnWrt0j372dONuvQRKwapdnQ4yegKesC3QBgZQh+c9SAkp7eIM6z mHAPAI45kmgvhwHN/gb+x2PyynflMQAKp2gAWtyi1lZk5c7afiHIcL+LKGkZQuakvRjh4j 9QWtH/5JAxvDp9wN/l5+vrJ3nI7AJj0= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-417-wMiRFWXmPxejMKYYvjH6vg-1; Fri, 04 Nov 2022 14:20:57 -0400 X-MC-Unique: wMiRFWXmPxejMKYYvjH6vg-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 11297811E67; Fri, 4 Nov 2022 18:20:57 +0000 (UTC) Received: from llong.com (unknown [10.22.34.155]) by smtp.corp.redhat.com (Postfix) with ESMTP id 940ADC15BA5; Fri, 4 Nov 2022 18:20:56 +0000 (UTC) From: Waiman Long To: Tejun Heo , Jens Axboe Cc: cgroups@vger.kernel.org, linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, Ming Lei , Andy Shevchenko , Andrew Morton , =?utf-8?q?Michal_Koutn=C3=BD?= , Hillf Danton , Waiman Long Subject: [PATCH v9 1/3] blk-cgroup: Return -ENOMEM directly in blkcg_css_alloc() error path Date: Fri, 4 Nov 2022 14:20:48 -0400 Message-Id: <20221104182050.342908-2-longman@redhat.com> In-Reply-To: <20221104182050.342908-1-longman@redhat.com> References: <20221104182050.342908-1-longman@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.8 X-Spam-Status: No, score=-3.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1748591012410326155?= X-GMAIL-MSGID: =?utf-8?q?1748591012410326155?= For blkcg_css_alloc(), the only error that will be returned is -ENOMEM. Simplify error handling code by returning this error directly instead of setting an intermediate "ret" variable. Signed-off-by: Waiman Long Reviewed-by: Ming Lei Acked-by: Tejun Heo --- block/blk-cgroup.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/block/blk-cgroup.c b/block/blk-cgroup.c index 6a5c849ee061..af8a4d2d1fd1 100644 --- a/block/blk-cgroup.c +++ b/block/blk-cgroup.c @@ -1139,7 +1139,6 @@ static struct cgroup_subsys_state * blkcg_css_alloc(struct cgroup_subsys_state *parent_css) { struct blkcg *blkcg; - struct cgroup_subsys_state *ret; int i; mutex_lock(&blkcg_pol_mutex); @@ -1148,10 +1147,8 @@ blkcg_css_alloc(struct cgroup_subsys_state *parent_css) blkcg = &blkcg_root; } else { blkcg = kzalloc(sizeof(*blkcg), GFP_KERNEL); - if (!blkcg) { - ret = ERR_PTR(-ENOMEM); + if (!blkcg) goto unlock; - } } for (i = 0; i < BLKCG_MAX_POLS ; i++) { @@ -1168,10 +1165,9 @@ blkcg_css_alloc(struct cgroup_subsys_state *parent_css) continue; cpd = pol->cpd_alloc_fn(GFP_KERNEL); - if (!cpd) { - ret = ERR_PTR(-ENOMEM); + if (!cpd) goto free_pd_blkcg; - } + blkcg->cpd[i] = cpd; cpd->blkcg = blkcg; cpd->plid = i; @@ -1200,7 +1196,7 @@ blkcg_css_alloc(struct cgroup_subsys_state *parent_css) kfree(blkcg); unlock: mutex_unlock(&blkcg_pol_mutex); - return ret; + return ERR_PTR(-ENOMEM); } static int blkcg_css_online(struct cgroup_subsys_state *css)