Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp3689906pxb; Mon, 1 Nov 2021 18:57:28 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzU+kfqd/SSUER0G3EGDyeJFQivLD1jvCJvOsyzV3eoWSpLiQRyppKYOvnAKRVS9J9vZMUR X-Received: by 2002:a17:907:3f9d:: with SMTP id hr29mr13036655ejc.369.1635818248495; Mon, 01 Nov 2021 18:57:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1635818248; cv=none; d=google.com; s=arc-20160816; b=PFLkv7NDpVWAiX5TsK7aGeGqCRFx17fVYPreoc2loHXWT1wQhiGrwYwRcyipl41Yab o/pr8U1a3bHMhmIucyX+IhsjMv8f2qIJuHlkIacV5dXuiaSInS9gDoZ8NsjQiGiYliXV 87Gm3M5qevdgKbsTLG+YrjiKOSGmNPU/1+hfKxtNvsCpkhU2sTjU6h+b1ZLyo9J9LNk8 dPaNvpax0jQEAjCP3U7DBM1KKJU9OIKDUnvVqoFflSl7NhWbuP3HdmgK/q80YqEsUWKL CidMmM7tPmy8fo2VrLfCnzbJaJU79pDijttYyPXhtNAcvnmQfGmk00qZhsr2rzekmNRp b4mw== 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 :message-id:date:subject:cc:to:from; bh=MmJdR8EnKxQN0KzKYLBG3t3qbmlUXnfSb+EWVXuGc0s=; b=0h3XMAdrvN2In+J+H3lJu1BTaAWMKECuGmpr8QUwOwqzfbObqyG9BjrsTXdibSrB5Y CvGmgZsuEbC4+a/At8dxyeJH6KZ+HjOgpKtmO5YsKYHbsRH3P/hsCidBxa97seIINy3i YIUTmM3tAVe30KWbRTR1AUP4EI09VJq5w8fsx85erxURkcLUCuLH9dDhmO4ZbRLidwZb 3zyeKWk4jUDoFQdYxujCpKR+f/aDQER3yCHaNqXLfdRkgVTpLeXQBDS/JFD+KBVJg9g9 yAwDKq1xYAyR3OrV+SY/xkTHB8RkInuzTUEWzq002u0nfGZY/kgMv1QfliFepcFMrC7o CRWQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=huawei.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id g13si31641555edz.599.2021.11.01.18.56.46; Mon, 01 Nov 2021 18:57:28 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229699AbhKBB47 (ORCPT + 99 others); Mon, 1 Nov 2021 21:56:59 -0400 Received: from szxga01-in.huawei.com ([45.249.212.187]:30892 "EHLO szxga01-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229486AbhKBB47 (ORCPT ); Mon, 1 Nov 2021 21:56:59 -0400 Received: from dggemv704-chm.china.huawei.com (unknown [172.30.72.56]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4HjtBC32Nkzcb4n; Tue, 2 Nov 2021 09:49:39 +0800 (CST) Received: from kwepemm600009.china.huawei.com (7.193.23.164) by dggemv704-chm.china.huawei.com (10.3.19.47) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.15; Tue, 2 Nov 2021 09:54:19 +0800 Received: from huawei.com (10.175.127.227) by kwepemm600009.china.huawei.com (7.193.23.164) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.15; Tue, 2 Nov 2021 09:54:18 +0800 From: Yu Kuai To: , , CC: , , , Subject: [PATCH] blk-cgroup: fix missing put device in error path from blkg_conf_pref() Date: Tue, 2 Nov 2021 10:07:05 +0800 Message-ID: <20211102020705.2321858-1-yukuai3@huawei.com> X-Mailer: git-send-email 2.31.1 MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII X-Originating-IP: [10.175.127.227] X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) To kwepemm600009.china.huawei.com (7.193.23.164) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org If blk_queue_enter() failed due to queue is dying, the blkdev_put_no_open() is needed because blkcg_conf_open_bdev() succeeded. Fixes: 0c9d338c8443 ("blk-cgroup: synchronize blkg creation against policy deactivation") Signed-off-by: Yu Kuai --- block/blk-cgroup.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/block/blk-cgroup.c b/block/blk-cgroup.c index 88b1fce90520..663aabfeba18 100644 --- a/block/blk-cgroup.c +++ b/block/blk-cgroup.c @@ -640,7 +640,7 @@ int blkg_conf_prep(struct blkcg *blkcg, const struct blkcg_policy *pol, */ ret = blk_queue_enter(q, 0); if (ret) - return ret; + goto fail; rcu_read_lock(); spin_lock_irq(&q->queue_lock); @@ -676,13 +676,13 @@ int blkg_conf_prep(struct blkcg *blkcg, const struct blkcg_policy *pol, new_blkg = blkg_alloc(pos, q, GFP_KERNEL); if (unlikely(!new_blkg)) { ret = -ENOMEM; - goto fail; + goto fail_exit_queue; } if (radix_tree_preload(GFP_KERNEL)) { blkg_free(new_blkg); ret = -ENOMEM; - goto fail; + goto fail_exit_queue; } rcu_read_lock(); @@ -722,9 +722,10 @@ int blkg_conf_prep(struct blkcg *blkcg, const struct blkcg_policy *pol, fail_unlock: spin_unlock_irq(&q->queue_lock); rcu_read_unlock(); +fail_exit_queue: + blk_queue_exit(q); fail: blkdev_put_no_open(bdev); - blk_queue_exit(q); /* * If queue was bypassing, we should retry. Do so after a * short msleep(). It isn't strictly necessary but queue -- 2.31.1