t/io_uring: memset() allocated memory
authorKeith Busch <kbusch@kernel.org>
Mon, 11 Mar 2019 16:46:47 +0000 (10:46 -0600)
committerJens Axboe <axboe@kernel.dk>
Mon, 11 Mar 2019 16:46:47 +0000 (10:46 -0600)
But I totally rushed this patch and just sent it once I heard it "worked",
and it really doesn't because malloc doesn't zero the buffer. My mistake,
kzalloc spoiled me. Here's the fix:

Fixes: e39863e3cb61 ("t/io_uring: add depth options")
Signed-off-by: Jens Axboe <axboe@kernel.dk>
t/io_uring.c

index 36aede9ba266b949d662034c97b16e5b2d483787..363cba3eba86c9c2c80098edaa9c9791a93145a9 100644 (file)
@@ -526,7 +526,8 @@ int main(int argc, char *argv[])
                }
        }
 
                }
        }
 
-       submitter = malloc(sizeof(*submitter) * depth * sizeof(struct iovec));
+       submitter = malloc(sizeof(*submitter) + depth * sizeof(struct iovec));
+       memset(submitter, 0, sizeof(*submitter) + depth * sizeof(struct iovec));
        s = submitter;
 
        flags = O_RDONLY | O_NOATIME;
        s = submitter;
 
        flags = O_RDONLY | O_NOATIME;