From nobody Fri Sep 25 04:44:23 2026 Received: from cstnet.cn (smtp25.cstnet.cn [159.226.251.25]) (using TLSv1.2 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 730F84C9E1E; Wed, 16 Sep 2026 17:17:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=159.226.251.25 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789579073; cv=none; b=o05AbQUh7wN/WVopv3WrvzZ7CNg4UBX1MgMKX5GTsNjlsonFbc4Exn1oef6lytdoNCT5rrkYptWOE16n5NFxq4KSu6lMZbAICpmdcevLnCby+RCHyFWnix0ZmvS+yi1L+8xb4p16as800wV6yKm7Ma88qFf81WR6pKZpyVHbivA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789579073; c=relaxed/simple; bh=VYZDjmWiFK9QefEGnEpJE3PllBDLkn2CNMt2n8yB+Yc=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=OfF0nLYfUIg/54IRWtHmn9TTUiPGRHSRIJFhLWJQAL+hS2aypX/aDG1XhqMeIy5sDsXjl1A8x6TKBBgNd+IRnqNXtaDyrxPTG578d7mrnT6/55JcAkC53b6rOM6MNA6nJq4AKyneJDoEp+FDNxg7vkKPdQHfd8f2Pjfu2REAGEA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=iscas.ac.cn; spf=pass smtp.mailfrom=iscas.ac.cn; arc=none smtp.client-ip=159.226.251.25 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=iscas.ac.cn Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=iscas.ac.cn Received: from dfae2b116770.home.arpa (unknown [36.110.52.2]) by APP-05 (Coremail) with SMTP id zQCowACXAj04z6pq3HVuCA--.22246S2; Thu, 17 Sep 2026 01:17:44 +0800 (CST) From: Wentao Liang To: clm@fb.com Cc: dsterba@suse.com, josef@toxicpanda.com, linux-btrfs@vger.kernel.org, linux-kernel@vger.kernel.org, naohiro.aota@wdc.com, Wentao Liang , stable@vger.kernel.org Subject: [PATCH] btrfs: Fix block group reference leak in btrfs_repair_one_zone() Date: Wed, 16 Sep 2026 17:17:16 +0000 Message-Id: <20260916171716.2087024-1-vulab@iscas.ac.cn> X-Mailer: git-send-email 2.34.1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-CM-TRANSID: zQCowACXAj04z6pq3HVuCA--.22246S2 X-Coremail-Antispam: 1UD129KBjvJXoW7uF43Jr47AFykAr4fCF1rZwb_yoW8Xry3pr Z3C3W5trs8Aw4ruFWDGa1Fvw1Sg3ykGa1UGF95Kw4xJw13ta45t39akw1Yyr10kFy8Xr40 qFn8A3WUZwsxAF7anT9S1TB71UUUUU7qnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUvY14x267AKxVW8JVW5JwAFc2x0x2IEx4CE42xK8VAvwI8IcIk0 rVWrJVCq3wAFIxvE14AKwVWUJVWUGwA2ocxC64kIII0Yj41l84x0c7CEw4AK67xGY2AK02 1l84ACjcxK6xIIjxv20xvE14v26ryj6F1UM28EF7xvwVC0I7IYx2IY6xkF7I0E14v26F4j 6r4UJwA2z4x0Y4vEx4A2jsIE14v26r4UJVWxJr1l84ACjcxK6I8E87Iv6xkF7I0E14v26r 4UJVWxJr1le2I262IYc4CY6c8Ij28IcVAaY2xG8wAqx4xG64xvF2IEw4CE5I8CrVC2j2Wl Yx0E2Ix0cI8IcVAFwI0_JF0_Jw1lYx0Ex4A2jsIE14v26r4j6F4UMcvjeVCFs4IE7xkEbV WUJVW8JwACjcxG0xvY0x0EwIxGrwACjI8F5VA0II8E6IAqYI8I648v4I1lc7CjxVAaw2AF wI0_JF0_Jw1l42xK82IYc2Ij64vIr41l4I8I3I0E4IkC6x0Yz7v_Jr0_Gr1lx2IqxVAqx4 xG67AKxVWUJVWUGwC20s026x8GjcxK67AKxVWUGVWUWwC2zVAF1VAY17CE14v26r1q6r43 MIIYrxkI7VAKI48JMIIF0xvE2Ix0cI8IcVAFwI0_JFI_Gr1lIxAIcVC0I7IYx2IY6xkF7I 0E14v26F4j6r4UJwCI42IY6xAIw20EY4v20xvaj40_Jr0_JF4lIxAIcVC2z280aVAFwI0_ Gr0_Cr1lIxAIcVC2z280aVCY1x0267AKxVW8Jr0_Cr1UYxBIdaVFxhVjvjDU0xZFpf9x0J USLvNUUUUU= X-CM-SenderInfo: pyxotu46lvutnvoduhdfq/1tbiCRMMA2qqozVkqQADsN Content-Type: text/plain; charset="utf-8" btrfs_repair_one_zone() hands the block group reference taken by btrfs_lookup_block_group() over to relocating_repair_kthread(), which drops it. However the return value of kthread_run() is not checked, so when the kernel thread fails to spawn, nothing executes the put and the block group reference is leaked. Check kthread_run() and drop the reference if the thread failed to start. Fixes: f7ef5287a63d ("btrfs: zoned: relocate block group to repair IO failu= re in zoned filesystems") Cc: stable@vger.kernel.org Signed-off-by: Wentao Liang Reviewed-by: Boris Burkov --- fs/btrfs/volumes.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c index a88e68f90564..541bcd65a6f6 100644 --- a/fs/btrfs/volumes.c +++ b/fs/btrfs/volumes.c @@ -8770,6 +8770,7 @@ static int relocating_repair_kthread(void *data) bool btrfs_repair_one_zone(struct btrfs_fs_info *fs_info, u64 logical) { struct btrfs_block_group *cache; + struct task_struct *task; =20 if (!btrfs_is_zoned(fs_info)) return false; @@ -8787,8 +8788,10 @@ bool btrfs_repair_one_zone(struct btrfs_fs_info *fs_= info, u64 logical) return true; } =20 - kthread_run(relocating_repair_kthread, cache, - "btrfs-relocating-repair"); + task =3D kthread_run(relocating_repair_kthread, cache, + "btrfs-relocating-repair"); + if (IS_ERR(task)) + btrfs_put_block_group(cache); =20 return true; } --=20 2.34.1