From db6e1105aaa9c499281498653387bedd08e4611d Mon Sep 17 00:00:00 2001 From: Ziye Yang Date: Thu, 26 Jul 2018 10:23:39 +0800 Subject: [PATCH] blobfs: add the check for cache_buffer Though the buffer can be allocated in the normal case, however we still need to check it. Change-Id: I483c7bd083c24590295e44473674c7b8ed30e9da Signed-off-by: Ziye Yang Reviewed-on: https://review.gerrithub.io/420462 Tested-by: SPDK CI Jenkins Chandler-Test-Pool: SPDK Automated Test System Reviewed-by: Ben Walker Reviewed-by: Jim Harris --- lib/blobfs/blobfs.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib/blobfs/blobfs.c b/lib/blobfs/blobfs.c index 0eabb2816..fb1df68b4 100644 --- a/lib/blobfs/blobfs.c +++ b/lib/blobfs/blobfs.c @@ -2243,6 +2243,12 @@ check_readahead(struct spdk_file *file, uint64_t offset) args->file = file; args->op.readahead.offset = offset; args->op.readahead.cache_buffer = cache_insert_buffer(file, offset); + if (!args->op.readahead.cache_buffer) { + BLOBFS_TRACE(file, "Cannot allocate buf for offset=%jx\n", offset); + free(args); + return; + } + args->op.readahead.cache_buffer->in_progress = true; if (file->length < (offset + CACHE_BUFFER_SIZE)) { args->op.readahead.length = file->length & (CACHE_BUFFER_SIZE - 1);