From e152aa8e51798a090a7a7ecb2799f605df930761 Mon Sep 17 00:00:00 2001 From: Ziye Yang Date: Wed, 25 Jul 2018 13:24:14 +0800 Subject: [PATCH] blobfs: add the check for buf allocation If it fails to allocate the buf, we should conduct the error handling. Change-Id: If36b2dd84236052c777f5007ecbf7295e1c1d3eb Signed-off-by: Ziye Yang Reviewed-on: https://review.gerrithub.io/420334 Tested-by: SPDK CI Jenkins Chandler-Test-Pool: SPDK Automated Test System Reviewed-by: Ben Walker Reviewed-by: Jim Harris --- lib/blobfs/blobfs.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/lib/blobfs/blobfs.c b/lib/blobfs/blobfs.c index 60bc482c0..2f4dc51a7 100644 --- a/lib/blobfs/blobfs.c +++ b/lib/blobfs/blobfs.c @@ -1608,6 +1608,13 @@ __readwrite(struct spdk_file *file, struct spdk_io_channel *_channel, __get_page_parameters(file, offset, length, &start_page, &page_size, &num_pages); pin_buf_length = num_pages * page_size; args->op.rw.pin_buf = spdk_dma_malloc(pin_buf_length, 4096, NULL); + if (args->op.rw.pin_buf == NULL) { + SPDK_DEBUGLOG(SPDK_LOG_BLOBFS, "Failed to allocate buf for: file=%s offset=%jx length=%jx\n", + file->name, offset, length); + free_fs_request(req); + cb_fn(cb_arg, -ENOMEM); + return; + } args->op.rw.start_page = start_page; args->op.rw.num_pages = num_pages;