summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@lst.de>2026-10-29 16:03:34 +0100
committerJens Axboe <axboe@kernel.dk>2026-10-29 09:29:19 -0600
commit134ffb0755626c91af82fc7debc8b6f75f1f777e (patch)
tree6796924e17a7e219288823788c0883aab2876af2
parent5e9929e2f03c79574e76605e1a82509575db2d30 (diff)
downloadlinux-134ffb0755626c91af82fc7debc8b6f75f1f777e.tar.gz
linux-134ffb0755626c91af82fc7debc8b6f75f1f777e.zip
zloop: fput file after failed zone init
Clean up after failure in zloop_init_zone, as the caller only cleans up the zones before the current one. Fixes: eb0570c7df23 ("block: new zoned loop block device driver") Signed-off-by: Christoph Hellwig <hch@lst.de> Link: https://patch.msgid.link/20261029150353.2503201-4-hch@lst.de Signed-off-by: Jens Axboe <axboe@kernel.dk>
-rw-r--r--drivers/block/zloop.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/drivers/block/zloop.c b/drivers/block/zloop.c
index 3dc484e3c700..f0aca9d43851 100644
--- a/drivers/block/zloop.c
+++ b/drivers/block/zloop.c
@@ -1135,7 +1135,7 @@ static int zloop_init_zone(struct zloop_device *zlo, struct zloop_options *opts,
if (zlo->block_size) {
ret = zloop_get_block_size(zlo, zone);
if (ret)
- return ret;
+ goto out_fput;
}
if (zone_no < zlo->nr_conv_zones) {
@@ -1150,14 +1150,14 @@ static int zloop_init_zone(struct zloop_device *zlo, struct zloop_options *opts,
ret = vfs_getattr(&zone->file->f_path, &stat, STATX_SIZE, 0);
if (ret < 0) {
pr_err("Failed to get zone %u file stat\n", zone_no);
- return ret;
+ goto out_fput;
}
file_sectors = stat.size >> SECTOR_SHIFT;
if (restore && file_sectors != zlo->zone_size) {
pr_err("Invalid conventional zone %u file size (%llu sectors != %llu)\n",
zone_no, file_sectors, zlo->zone_capacity);
- return ret;
+ goto out_fput;
}
ret = vfs_truncate(&zone->file->f_path,
@@ -1165,15 +1165,21 @@ static int zloop_init_zone(struct zloop_device *zlo, struct zloop_options *opts,
if (ret < 0) {
pr_err("Failed to truncate zone %u file (err=%d)\n",
zone_no, ret);
- return ret;
+ goto out_fput;
}
} else {
/* Sequential zone file. */
mutex_lock(&zone->lock);
ret = zloop_update_seq_zone(zlo, zone_no);
mutex_unlock(&zone->lock);
+ if (ret)
+ goto out_fput;
}
+ return 0;
+
+out_fput:
+ fput(zone->file);
return ret;
}