From 4f936f0cd8b8d294bd1dcc7b7b1810b2c886452d Mon Sep 17 00:00:00 2001 From: Thomas Schoebel-Theuer Date: Tue, 2 Dec 2014 12:23:45 +0100 Subject: [PATCH] bio: fix invalid block allocations --- kernel/mars_bio.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/kernel/mars_bio.c b/kernel/mars_bio.c index dde4732d..87641dc7 100644 --- a/kernel/mars_bio.c +++ b/kernel/mars_bio.c @@ -294,6 +294,9 @@ static int bio_ref_get(struct bio_output *output, struct mref_object *mref) if (!mref->ref_data) { // buffered IO. + if (unlikely(mref->ref_len <= 0)) { + goto done; + } status = -ENOMEM; mref->ref_data = brick_block_alloc(mref->ref_pos, (mref_a->alloc_len = mref->ref_len)); if (unlikely(!mref->ref_data)) {