From: Bart Van Assche Date: Fri, 5 Jun 2026 18:00:59 +0000 (-0700) Subject: block/blk-iocost: Combine two error paths in ioc_qos_write() X-Git-Url: http://git.ipfire.org/gitweb/?a=commitdiff_plain;h=6a7717a2df6c01b2158979f311ddf4cb35b8987f;p=thirdparty%2Flinux.git block/blk-iocost: Combine two error paths in ioc_qos_write() Reduce code duplication by combining two error paths. No functionality has been changed. Suggested-by: Christoph Hellwig Reviewed-by: Hannes Reinecke Reviewed-by: Christoph Hellwig Cc: Tejun Heo Signed-off-by: Bart Van Assche Reviewed-by: Chaitanya Kulkarni Link: https://patch.msgid.link/80d4fc1ecd5eaf187c0a31c63a1033a7326d4c7e.1780682325.git.bvanassche@acm.org Signed-off-by: Jens Axboe --- diff --git a/block/blk-iocost.c b/block/blk-iocost.c index 3e4e28ecc21f0..050bfbc6d8062 100644 --- a/block/blk-iocost.c +++ b/block/blk-iocost.c @@ -3239,7 +3239,7 @@ static ssize_t ioc_qos_write(struct kernfs_open_file *of, char *input, bool enable, user; char *body, *p; unsigned long memflags; - int ret; + int ret = 0; blkg_conf_init(&ctx, input); @@ -3251,14 +3251,14 @@ static ssize_t ioc_qos_write(struct kernfs_open_file *of, char *input, disk = ctx.bdev->bd_disk; if (!queue_is_mq(disk->queue)) { ret = -EOPNOTSUPP; - goto err; + goto close_bdev; } ioc = q_to_ioc(disk->queue); if (!ioc) { ret = blk_iocost_init(disk); if (ret) - goto err; + goto close_bdev; ioc = q_to_ioc(disk->queue); } @@ -3362,15 +3362,15 @@ static ssize_t ioc_qos_write(struct kernfs_open_file *of, char *input, blk_mq_unquiesce_queue(disk->queue); +close_bdev: blkg_conf_close_bdev_frozen(&ctx, memflags); - return nbytes; + return ret ?: nbytes; + einval: spin_unlock_irq(&ioc->lock); blk_mq_unquiesce_queue(disk->queue); ret = -EINVAL; -err: - blkg_conf_close_bdev_frozen(&ctx, memflags); - return ret; + goto close_bdev; } static u64 ioc_cost_model_prfill(struct seq_file *sf,