From df930739718562130e74444e82103542bf04ad92 Mon Sep 17 00:00:00 2001 From: Zach Brown Date: Fri, 26 Aug 2016 16:51:47 -0700 Subject: [PATCH] scoutfs: don't unlock err bh after validation If block validation failed then we'd end up trying to unlock an IS_ERR buffer_head pointer. Fix it so that we drop the ref and set the pointer after unlocking. Signed-off-by: Zach Brown --- kmod/src/block.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/kmod/src/block.c b/kmod/src/block.c index 4f82eae9..faf9ae33 100644 --- a/kmod/src/block.c +++ b/kmod/src/block.c @@ -194,14 +194,16 @@ struct buffer_head *scoutfs_block_read(struct super_block *sb, u64 blkno) lock_buffer(bh); if (!buffer_scoutfs_verified(bh)) { ret = verify_block_header(sbi, bh); - if (ret < 0) { - scoutfs_block_put(bh); - bh = ERR_PTR(ret); - } else { + if (!ret) set_buffer_scoutfs_verified(bh); - } + } else { + ret = 0; } unlock_buffer(bh); + if (ret < 0) { + scoutfs_block_put(bh); + bh = ERR_PTR(ret); + } } out: