From: Liu Bo Date: Thu, 23 Jun 2016 01:32:06 +0000 (-0700) Subject: Btrfs: fix BUG_ON in btrfs_submit_compressed_write X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=f5daf2c780f2ddfddbf98f2eb668f026c4dd2e5d;p=GitHub%2FLineageOS%2Fandroid_kernel_motorola_exynos9610.git Btrfs: fix BUG_ON in btrfs_submit_compressed_write This is similar to btrfs_submit_compressed_read(), if we fail after bio is allocated, then we can use bio_endio() and errors are saved in bio->bi_error. But please note that we don't return errors to its caller because the caller assumes it won't call endio to cleanup on error. Signed-off-by: Liu Bo Signed-off-by: David Sterba --- diff --git a/fs/btrfs/compression.c b/fs/btrfs/compression.c index 658c39b70fba..7a4d9c81aa2a 100644 --- a/fs/btrfs/compression.c +++ b/fs/btrfs/compression.c @@ -402,7 +402,10 @@ int btrfs_submit_compressed_write(struct inode *inode, u64 start, } ret = btrfs_map_bio(root, WRITE, bio, 0, 1); - BUG_ON(ret); /* -ENOMEM */ + if (ret) { + bio->bi_error = ret; + bio_endio(bio); + } bio_put(bio); @@ -432,7 +435,10 @@ int btrfs_submit_compressed_write(struct inode *inode, u64 start, } ret = btrfs_map_bio(root, WRITE, bio, 0, 1); - BUG_ON(ret); /* -ENOMEM */ + if (ret) { + bio->bi_error = ret; + bio_endio(bio); + } bio_put(bio); return 0;