public inbox for linux-btrfs@vger.kernel.org
 help / color / mirror / Atom feed
From: Christoph Hellwig <hch@lst.de>
To: dsterba@suse.com
Cc: josef@toxicpanda.com, linux-btrfs@vger.kernel.org,
	syzbot+a2c720e0f056114ea7c6@syzkaller.appspotmail.com
Subject: [PATCH] btrfs: don't call destroy_workqueue on NULL workqueues
Date: Thu, 28 Apr 2022 05:53:41 -0700	[thread overview]
Message-ID: <20220428125341.4152527-1-hch@lst.de> (raw)

Unlike the btrfs_workueue code, the kernel workqueues don't like their
cleaup function called on a NULL pointer, so add checks for them.

Fixes: a5eec25648da ("btrfs: use a normal workqueue for rmw_workers")
Reported-by: syzbot+a2c720e0f056114ea7c6@syzkaller.appspotmail.com
Signed-off-by: Christoph Hellwig <hch@lst.de>
Tested-by: syzbot+a2c720e0f056114ea7c6@syzkaller.appspotmail.com
---
 fs/btrfs/disk-io.c | 3 ++-
 fs/btrfs/scrub.c   | 9 ++++++---
 2 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c
index 307230436ecd6..fd8d91947d3fc 100644
--- a/fs/btrfs/disk-io.c
+++ b/fs/btrfs/disk-io.c
@@ -2283,7 +2283,8 @@ static void btrfs_stop_all_workers(struct btrfs_fs_info *fs_info)
 	btrfs_destroy_workqueue(fs_info->workers);
 	btrfs_destroy_workqueue(fs_info->endio_workers);
 	btrfs_destroy_workqueue(fs_info->endio_raid56_workers);
-	destroy_workqueue(fs_info->rmw_workers);
+	if (fs_info->rmw_workers)
+		destroy_workqueue(fs_info->rmw_workers);
 	btrfs_destroy_workqueue(fs_info->endio_write_workers);
 	btrfs_destroy_workqueue(fs_info->endio_freespace_worker);
 	btrfs_destroy_workqueue(fs_info->delayed_workers);
diff --git a/fs/btrfs/scrub.c b/fs/btrfs/scrub.c
index a614ddde8c624..3985225f27be5 100644
--- a/fs/btrfs/scrub.c
+++ b/fs/btrfs/scrub.c
@@ -3967,9 +3967,12 @@ static void scrub_workers_put(struct btrfs_fs_info *fs_info)
 		fs_info->scrub_parity_workers = NULL;
 		mutex_unlock(&fs_info->scrub_lock);
 
-		destroy_workqueue(scrub_workers);
-		destroy_workqueue(scrub_wr_comp);
-		destroy_workqueue(scrub_parity);
+		if (scrub_workers)
+			destroy_workqueue(scrub_workers);
+		if (scrub_wr_comp)
+			destroy_workqueue(scrub_wr_comp);
+		if (scrub_parity)
+			destroy_workqueue(scrub_parity);
 	}
 }
 
-- 
2.30.2


             reply	other threads:[~2022-04-28 12:53 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-04-28 12:53 Christoph Hellwig [this message]
2022-04-28 15:02 ` [PATCH] btrfs: don't call destroy_workqueue on NULL workqueues David Sterba

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220428125341.4152527-1-hch@lst.de \
    --to=hch@lst.de \
    --cc=dsterba@suse.com \
    --cc=josef@toxicpanda.com \
    --cc=linux-btrfs@vger.kernel.org \
    --cc=syzbot+a2c720e0f056114ea7c6@syzkaller.appspotmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox