Test malloc result when allocation size is tunable
[fio.git] / filesetup.c
index bcf95bd5a78785b2b4431db3b522fc12378d7bcb..ce19cf0b127d294e6d8d4c012595863552598b30 100644 (file)
@@ -160,6 +160,10 @@ static int extend_file(struct thread_data *td, struct fio_file *f)
        }
 
        b = malloc(td->o.max_bs[DDIR_WRITE]);
        }
 
        b = malloc(td->o.max_bs[DDIR_WRITE]);
+       if (!b) {
+               td_verror(td, errno, "malloc");
+               goto err;
+       }
 
        left = f->real_file_size;
        while (left && !td->terminate) {
 
        left = f->real_file_size;
        while (left && !td->terminate) {
@@ -243,6 +247,11 @@ static int pre_read_file(struct thread_data *td, struct fio_file *f)
 
        bs = td->o.max_bs[DDIR_READ];
        b = malloc(bs);
 
        bs = td->o.max_bs[DDIR_READ];
        b = malloc(bs);
+       if (!b) {
+               td_verror(td, errno, "malloc");
+               ret = 1;
+               goto error;
+       }
        memset(b, 0, bs);
 
        if (lseek(f->fd, f->file_offset, SEEK_SET) < 0) {
        memset(b, 0, bs);
 
        if (lseek(f->fd, f->file_offset, SEEK_SET) < 0) {