]> www.infradead.org Git - users/sagi/nvme-cli.git/commitdiff
nvme: Use correct data buffer size
authorDaniel Wagner <dwagner@suse.de>
Tue, 6 Jun 2023 15:21:55 +0000 (17:21 +0200)
committerDaniel Wagner <wagi@monom.org>
Tue, 6 Jun 2023 16:04:39 +0000 (18:04 +0200)
The submit_io command is using the buffer size provided by the
user. But this size argument might be updated and the correct length
for the buffer is buffer_size. Thus use this value and not the
initial length.

Signed-off-by: Daniel Wagner <dwagner@suse.de>
nvme.c

diff --git a/nvme.c b/nvme.c
index 7e877fb40c3b031ed40c539cea103a5ce94e462c..b5b058573b98add95d629827fe0fed57a91d6de6 100644 (file)
--- a/nvme.c
+++ b/nvme.c
@@ -7672,7 +7672,7 @@ static int submit_io(int opcode, char *command, const char *desc, int argc, char
        } else if (err) {
                nvme_show_status(err);
        } else {
-               if (!(opcode & 1) && write(dfd, (void *)buffer, cfg.data_size) < 0) {
+               if (!(opcode & 1) && write(dfd, (void *)buffer, buffer_size) < 0) {
                        nvme_show_error("write: %s: failed to write buffer to output file",
                                strerror(errno));
                        err = -EINVAL;