Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

selftests/ublk: fix garbage output in foreground mode

Initialize _evtfd to -1 in struct dev_ctx to prevent garbage output
when running kublk in foreground mode. Without this, _evtfd is
zero-initialized to 0 (stdin), and ublk_send_dev_event() writes
binary data to stdin which appears as garbage on the terminal.

Also fix debug message format string.

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>

authored by

Ming Lei and committed by
Jens Axboe
e7e1cc18 23e62cf7

+2 -1
+2 -1
tools/testing/selftests/ublk/kublk.c
··· 1274 1274 } 1275 1275 1276 1276 ret = ublk_start_daemon(ctx, dev); 1277 - ublk_dbg(UBLK_DBG_DEV, "%s: daemon exit %d\b", ret); 1277 + ublk_dbg(UBLK_DBG_DEV, "%s: daemon exit %d\n", __func__, ret); 1278 1278 if (ret < 0) 1279 1279 ublk_ctrl_del_dev(dev); 1280 1280 ··· 1620 1620 int option_idx, opt; 1621 1621 const char *cmd = argv[1]; 1622 1622 struct dev_ctx ctx = { 1623 + ._evtfd = -1, 1623 1624 .queue_depth = 128, 1624 1625 .nr_hw_queues = 2, 1625 1626 .dev_id = -1,