Fix compilation and checker errors in zoned series
cover Fix compilation and checker errors in zoned series
Hi David,
The Kbuild Robot and Julia reported two errors in the zoned series which have slipped thorugh.
Here are the fixes.
Johannes Thumshirn (2):
btrfs: fix compilation error for !CONFIG_BLK_DEV_ZONED
btrfs: fix double free in btrfs_get_dev_zone_info
fs/btrfs/zoned.c | 4 +++- fs/btrfs/zoned.h | 3 ++- 2 files changed, 5 insertions(+), 2 deletions(-)
Signature · 1 line
2.26.2
PATCH 1/2 btrfs: fix compilation error for !CONFIG_BLK_DEV_ZONED
The !CONFIG_BLK_DEV_ZONED case didn't compile correctly because the function btrfs_use_zoned_append() was declared as static inline in zoned.h resulting in multiple definitions of the function.
--- fs/btrfs/zoned.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
fs/btrfs/zoned.h +2 -1
@@ -148,7 +148,8 @@ static inline void btrfs_redirty_list_add(struct btrfs_transaction *trans, struct extent_buffer *eb) { }static inline void btrfs_free_redirty_list (struct btrfs_transaction *trans) { } -bool btrfs_use_zone_append (struct btrfs_inode *inode,struct extent_map *em) +static inline bool btrfs_use_zone_append (struct btrfs_inode *inode, +struct extent_map *em) {return false; }
Signature · 1 line
2.26.2
PATCH 2/2 btrfs: fix double free in btrfs_get_dev_zone_info
In reply to Johannes ThumshirnWhen we end up getting an unsupported zone model in btrfs_get_dev_zone_info() the default error handling case frees all allocated resources, but "zones" was already freed resulting in a double-free and "zone_info" is already assigned to device->zone_info resulting in a potential use-after-free.
For the double free we could also set 'zones = NULL' after freeing, but I think this way is more readable.
--- fs/btrfs/zoned.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
fs/btrfs/zoned.c +3 -1
@@ -425,7 +425,7 @@ int btrfs_get_dev_zone_info(struct btrfs_device *device)bdev_zoned_model (bdev), rcu_str_deref(device->name)); ret = -EOPNOTSUPP ; - goto out; + goto out_free_zone_info; } btrfs_info_in_rcu(fs_info,
@@ -437,9 +437,11 @@ int btrfs_get_dev_zone_info(struct btrfs_device *device) out:kfree (zones); +out_free_zone_info:bitmap_free (zone_info->empty_zones);bitmap_free (zone_info->seq_zones);kfree (zone_info); + device->zone_info =NULL ;return ret; }
Signature · 1 line
2.26.2
Quoted 10 lines · Johannes Thumshirn
Hi David,
The
KbuildRobot and Julia reported two errors in the zoned series which have slipped thorugh.Here are the fixes.
Johannes Thumshirn (2):
btrfs: fix compilation error for !CONFIG_BLK_DEV_ZONED
btrfs: fix double free inbtrfs_get_dev_zone_info
Folded, thanks.