From patchwork Tue Jun 6 07:32:03 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chao Yu X-Patchwork-Id: 103607 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp3213805vqr; Tue, 6 Jun 2023 00:42:17 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7vljYR3NtoBdwf5aqF2HwH9wUSvpe7o+ezFWhfyOi5KpRsWzXLfFbjFjpxposCmi/PQ9Zr X-Received: by 2002:a05:6358:b52f:b0:127:c478:6418 with SMTP id de47-20020a056358b52f00b00127c4786418mr1773219rwb.30.1686037337519; Tue, 06 Jun 2023 00:42:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686037337; cv=none; d=google.com; s=arc-20160816; b=S+NOr4gubH6cSvYkaLdM4RyEU8/97XTzzYfZnbM/UngQRG0h7gzMh9mqT0PY+cmU74 lozaj2NsORA1i/SBO47soOcrQzhg509tysewNHOjJyQV0gN7ScAg+yHa66GtPQ7ggPcC HPMtj0bXC0ru7qInnP/qcL8xzGYN5udBwtyoDGF1LNXEQ70N10CFKaAAK88YpeV67NYo jweV9dS9mf6bwsnZ9GEO+BERAyw6XFAdU42+UMyHurDDsg3s3rnT1iqUyOcnzl/xdRZj WmwSuqnlUZYhuz3L6K1lbpyhMNUSrJFGlWFvhwBfGb8JpN/2NVG5ED34606jEVCtk79o Mnng== 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:dkim-signature; bh=VcUT14cR8VLCdkhpIjFHPWk120ahOXXf6YkAF01wTvw=; b=cgwYmCzq7sPXhmAf+p5TAXvJ6NUktnlMEiK7G2TQUyOfw7rfpnRmsEnFURUlhbpAW3 WWDzThy0KJMTLEzpJ2SrsMd1TdGmfvfcYYHdGjMcHR2q6DmWOuZC4U+FnyO/347jcPVK /BUBkFTgvsi9OEMPDN6jJMDFi10s1hT72krSiVRaGkJ1v6oAqDndC+Sp0RdLJVr/dk5S RZ71vTRaQ3oAws/6g6kLq1YkZhUnQiJS/djAHxVi5ZaTZcax2C5eJ159ut1ZrxItLz6p o+RyxDEvJulwiqb0tCP51lEZBAAs6pPtqciK1BBZJ3eB0H14wB0BpRJNgi4sUhTR97PT rJtQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=L1KDGLqV; 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=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 7-20020a17090a1a4700b0024b27e48a27si8621220pjl.74.2023.06.06.00.42.05; Tue, 06 Jun 2023 00:42:17 -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=@kernel.org header.s=k20201202 header.b=L1KDGLqV; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236223AbjFFHcP (ORCPT + 99 others); Tue, 6 Jun 2023 03:32:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46400 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236148AbjFFHcN (ORCPT ); Tue, 6 Jun 2023 03:32:13 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D446E11A; Tue, 6 Jun 2023 00:32:12 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 68DEC62CB9; Tue, 6 Jun 2023 07:32:12 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2644FC433EF; Tue, 6 Jun 2023 07:32:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1686036731; bh=Ak0j0Hr5s4dVlzG32KaXySxXdetfo8cIUB4kqJq07T4=; h=From:To:Cc:Subject:Date:From; b=L1KDGLqVhGh+sVvUI3ToDKAxdVULNnFXTvV3964C9ha3o5I1TeW1XCjyfgMd8J3ws pxhfQRkKWRdwUnAR+kC2KXathXAHPKwvuX/WwwLQPHv9eqNloTqKJVQABzITZSIUFN MGGa1LK4qUzA9RDzUVpGr8W9YIgF33mOgLtxwfT4y68r/YryJ6d3v8u2Xk9qag/1up 8Boecj0X0M4nZXMxMqF+jYcXOcFsUFAHs1zW67Yxhg3pBFmA4tEgbg/D4SdhwAJO8c 3JuH0kEblnlLPo5mQ30719Xryv0/vqp/UEynYcnttSDDCY7jPRy6t//Q6wp+sjqg/i qZGutlyXFpO9w== From: Chao Yu To: Theodore Ts'o , Andreas Dilger Cc: linux-ext4@vger.kernel.org, linux-kernel@vger.kernel.org, Chao Yu Subject: [PATCH] ext4: fix to check return value of freeze_bdev() in ext4_shutdown() Date: Tue, 6 Jun 2023 15:32:03 +0800 Message-Id: <20230606073203.1310389-1-chao@kernel.org> X-Mailer: git-send-email 2.40.1 MIME-Version: 1.0 X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE 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?1767938286946592054?= X-GMAIL-MSGID: =?utf-8?q?1767938286946592054?= freeze_bdev() can fail due to a lot of reasons, it needs to check its reason before later process. Fixes: 783d94854499 ("ext4: add EXT4_IOC_GOINGDOWN ioctl") Signed-off-by: Chao Yu --- fs/ext4/ioctl.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/fs/ext4/ioctl.c b/fs/ext4/ioctl.c index f9a430152063..55be1b8a6360 100644 --- a/fs/ext4/ioctl.c +++ b/fs/ext4/ioctl.c @@ -797,6 +797,7 @@ static int ext4_shutdown(struct super_block *sb, unsigned long arg) { struct ext4_sb_info *sbi = EXT4_SB(sb); __u32 flags; + int ret; if (!capable(CAP_SYS_ADMIN)) return -EPERM; @@ -815,7 +816,9 @@ static int ext4_shutdown(struct super_block *sb, unsigned long arg) switch (flags) { case EXT4_GOING_FLAGS_DEFAULT: - freeze_bdev(sb->s_bdev); + ret = freeze_bdev(sb->s_bdev); + if (ret) + return ret; set_bit(EXT4_FLAGS_SHUTDOWN, &sbi->s_ext4_flags); thaw_bdev(sb->s_bdev); break;