From 58c94606707d60fc809e545dc78735fdbc57b06a Mon Sep 17 00:00:00 2001 From: imp Date: Sun, 1 Mar 2015 21:41:37 +0000 Subject: [PATCH] nandfs_meta_bread() calls bread() which can set bp to NULL in some error cases. Calling brelse() with a NULL pointer is not allowed, so only call brelse() when the bp is non-NULL. Reported by: Maxime Villard (reported as uninitialized variable) --- sys/fs/nandfs/bmap.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sys/fs/nandfs/bmap.c b/sys/fs/nandfs/bmap.c index 10dd0572331d..35f943565d12 100644 --- a/sys/fs/nandfs/bmap.c +++ b/sys/fs/nandfs/bmap.c @@ -317,7 +317,8 @@ bmap_truncate_indirect(struct nandfs_node *node, int level, nandfs_lbn_t *left, error = nandfs_bread_meta(node, lbn, NOCRED, 0, &bp); if (error) { - brelse(bp); + if (bp != NULL) + brelse(bp); return (error); }