xfs
[Top] [All Lists]

Re: [PATCH 08/11] xfsprogs: xfs_repair: fix possible null dereference in

To: Vivek Trivedi <t.vivek@xxxxxxxxxxx>
Subject: Re: [PATCH 08/11] xfsprogs: xfs_repair: fix possible null dereference in build_ino_tree
From: Dave Chinner <david@xxxxxxxxxxxxx>
Date: Thu, 3 Dec 2015 17:19:43 +1100
Cc: xfs@xxxxxxxxxxx, a.sahrawat@xxxxxxxxxxx, pankaj.m@xxxxxxxxxxx
Delivered-to: xfs@xxxxxxxxxxx
In-reply-to: <1449055167-19936-9-git-send-email-t.vivek@xxxxxxxxxxx>
References: <1449055167-19936-1-git-send-email-t.vivek@xxxxxxxxxxx> <1449055167-19936-9-git-send-email-t.vivek@xxxxxxxxxxx>
User-agent: Mutt/1.5.21 (2010-09-15)
On Wed, Dec 02, 2015 at 04:49:24PM +0530, Vivek Trivedi wrote:
> Fix possible null dereference in build_ino_tree if ino_rec is NULL.
> Reported by coverity.
> 
> Signed-off-by: Vivek Trivedi <t.vivek@xxxxxxxxxxx>
> ---
>  repair/phase5.c |    2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/repair/phase5.c b/repair/phase5.c
> index 109e37b..5d95e22 100644
> --- a/repair/phase5.c
> +++ b/repair/phase5.c
> @@ -1235,7 +1235,7 @@ build_ino_tree(xfs_mount_t *mp, xfs_agnumber_t agno,
>               if (lptr->modulo > 0)
>                       lptr->modulo--;
>  
> -             if (lptr->num_recs_pb > 0)
> +             if (lptr->num_recs_pb > 0 && ino_rec)
>                       prop_ino_cursor(mp, agno, btree_curs,
>                                       ino_rec->ino_startnum, 0);
>  

Another "can't happen" case. The only time that ino_rec can be zero
is if there are no inodes in the AG, and in that case
init_ino_cursor() initialises lptr->num_recs_pb = 0.

Cheers,

Dave.
-- 
Dave Chinner
david@xxxxxxxxxxxxx

<Prev in Thread] Current Thread [Next in Thread>