summaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
Diffstat (limited to 'examples')
-rw-r--r--examples/io_uring-cp.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/examples/io_uring-cp.c b/examples/io_uring-cp.c
index 1dd20fc..97f61aa 100644
--- a/examples/io_uring-cp.c
+++ b/examples/io_uring-cp.c
@@ -81,11 +81,16 @@ static int queue_read(struct io_uring *ring, off_t size, off_t offset)
struct io_uring_sqe *sqe;
struct io_data *data;
+ data = malloc(size + sizeof(*data));
+ if (!data)
+ return 1;
+
sqe = io_uring_get_sqe(ring);
- if (!sqe)
+ if (!sqe) {
+ free(data);
return 1;
+ }
- data = malloc(size + sizeof(*data));
data->read = 1;
data->offset = data->first_offset = offset;