All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] btrfs: don't call destroy_workqueue on NULL workqueues
@ 2022-04-28 12:53 Christoph Hellwig
  2022-04-28 15:02 ` David Sterba
  0 siblings, 1 reply; 2+ messages in thread
From: Christoph Hellwig @ 2022-04-28 12:53 UTC (permalink / raw)
  To: dsterba; +Cc: josef, linux-btrfs, syzbot+a2c720e0f056114ea7c6

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


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] btrfs: don't call destroy_workqueue on NULL workqueues
  2022-04-28 12:53 [PATCH] btrfs: don't call destroy_workqueue on NULL workqueues Christoph Hellwig
@ 2022-04-28 15:02 ` David Sterba
  0 siblings, 0 replies; 2+ messages in thread
From: David Sterba @ 2022-04-28 15:02 UTC (permalink / raw)
  To: Christoph Hellwig
  Cc: dsterba, josef, linux-btrfs, syzbot+a2c720e0f056114ea7c6

On Thu, Apr 28, 2022 at 05:53:41AM -0700, Christoph Hellwig wrote:
> 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

Thanks, folded to the patches.

> --- 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);

This is in "btrfs: use a normal workqueue for 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);

And this from "btrfs: use normal workqueues for scrub"

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-04-28 15:06 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-28 12:53 [PATCH] btrfs: don't call destroy_workqueue on NULL workqueues Christoph Hellwig
2022-04-28 15:02 ` David Sterba

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.