summaryrefslogtreecommitdiff
path: root/tools/testing
diff options
context:
space:
mode:
authorMing Lei <ming.lei@redhat.com>2026-01-13 11:58:01 +0300
committerJens Axboe <axboe@kernel.dk>2026-01-21 17:54:55 +0300
commit23e62cf75518825aac12e9a22bdc40f062428898 (patch)
treef6e47cea299c65875a7300e0518a3708e951051e /tools/testing
parent75aad5ffe099a1b1a342257236dc260493917ed2 (diff)
downloadlinux-23e62cf75518825aac12e9a22bdc40f062428898.tar.xz
selftests/ublk: fix error handling for starting device
Fix error handling in ublk_start_daemon() when start_dev fails: 1. Call ublk_ctrl_stop_dev() to cancel inflight uring_cmd before cleanup. Without this, the device deletion may hang waiting for I/O completion that will never happen. 2. Add fail_start label so that pthread_join() is called on the error path. This ensures proper thread cleanup when startup fails. Fixes: 6aecda00b7d1 ("selftests: ublk: add kernel selftests for ublk") Signed-off-by: Ming Lei <ming.lei@redhat.com> Reviewed-by: Caleb Sander Mateos <csander@purestorage.com> Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'tools/testing')
-rw-r--r--tools/testing/selftests/ublk/kublk.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/tools/testing/selftests/ublk/kublk.c b/tools/testing/selftests/ublk/kublk.c
index f52431fe9b6c..65f59e7b6972 100644
--- a/tools/testing/selftests/ublk/kublk.c
+++ b/tools/testing/selftests/ublk/kublk.c
@@ -1054,7 +1054,9 @@ static int ublk_start_daemon(const struct dev_ctx *ctx, struct ublk_dev *dev)
}
if (ret < 0) {
ublk_err("%s: ublk_ctrl_start_dev failed: %d\n", __func__, ret);
- goto fail;
+ /* stop device so that inflight uring_cmd can be cancelled */
+ ublk_ctrl_stop_dev(dev);
+ goto fail_start;
}
ublk_ctrl_get_info(dev);
@@ -1062,7 +1064,7 @@ static int ublk_start_daemon(const struct dev_ctx *ctx, struct ublk_dev *dev)
ublk_ctrl_dump(dev);
else
ublk_send_dev_event(ctx, dev, dev->dev_info.dev_id);
-
+fail_start:
/* wait until we are terminated */
for (i = 0; i < dev->nthreads; i++)
pthread_join(tinfo[i].thread, &thread_ret);