[PATCH 06/11] xfsprogs: xfs_db: check null derefernce after block_to_bt

Eric Sandeen sandeen at sandeen.net
Wed Dec 2 23:43:13 CST 2015


I think this is ok; another "should never happen" scenario,
so the ASSERT seems fine.

Reviewed-by: Eric Sandeen <sandeen at redhat.com>

On 12/2/15 5:19 AM, Vivek Trivedi wrote:
> add assert if block_to_bt returns NULL to avoid null pointer
> dereference and get backtrace.
> Reported by coverity.
> 
> Signed-off-by: Vivek Trivedi <t.vivek at samsung.com>
> ---
>  db/btblock.c |    3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/db/btblock.c b/db/btblock.c
> index 46140fc..91593f8 100644
> --- a/db/btblock.c
> +++ b/db/btblock.c
> @@ -180,6 +180,7 @@ btblock_key_offset(
>  	struct xfs_db_btree	*bt = block_to_bt(block);
>  	int			offset;
>  
> +	ASSERT(bt != NULL);
>  	ASSERT(startoff == 0);
>  	ASSERT(block->bb_level != 0);
>  
> @@ -201,6 +202,7 @@ btblock_ptr_offset(
>  	int			offset;
>  	int			maxrecs;
>  
> +	ASSERT(bt != NULL);
>  	ASSERT(startoff == 0);
>  	ASSERT(block->bb_level != 0);
>  
> @@ -225,6 +227,7 @@ btblock_rec_offset(
>  	struct xfs_db_btree	*bt = block_to_bt(block);
>  	int			offset;
>  
> +	ASSERT(bt != NULL);
>  	ASSERT(startoff == 0);
>  	ASSERT(block->bb_level == 0);
>  
> 



More information about the xfs mailing list