[PATCH 11/11] xfsprogs: xfs_repair: fix possible null pointer dereference in mark_standalone_inodes

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Fix possible null pointer dereference in mark_standalone_inodes by
rearranging and adding ASSERT for null irec.
Reported by coverity.

Signed-off-by: Vivek Trivedi <t.vivek@xxxxxxxxxxx>
---
 repair/phase6.c |    7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/repair/phase6.c b/repair/phase6.c
index e41bf20..1e5fc46 100644
--- a/repair/phase6.c
+++ b/repair/phase6.c
@@ -3088,11 +3088,11 @@ mark_standalone_inodes(xfs_mount_t *mp)
 	irec = find_inode_rec(mp, XFS_INO_TO_AGNO(mp, mp->m_sb.sb_rsumino),
 			XFS_INO_TO_AGINO(mp, mp->m_sb.sb_rsumino));
 
+	ASSERT(irec != NULL);
+
 	offset = XFS_INO_TO_AGINO(mp, mp->m_sb.sb_rsumino) -
 			irec->ino_startnum;
 
-	ASSERT(irec != NULL);
-
 	add_inode_reached(irec, offset);
 
 	if (fs_quotas)  {
@@ -3101,6 +3101,7 @@ mark_standalone_inodes(xfs_mount_t *mp)
 			irec = find_inode_rec(mp, XFS_INO_TO_AGNO(mp,
 						mp->m_sb.sb_uquotino),
 				XFS_INO_TO_AGINO(mp, mp->m_sb.sb_uquotino));
+			ASSERT(irec != NULL);
 			offset = XFS_INO_TO_AGINO(mp, mp->m_sb.sb_uquotino)
 					- irec->ino_startnum;
 			add_inode_reached(irec, offset);
@@ -3110,6 +3111,7 @@ mark_standalone_inodes(xfs_mount_t *mp)
 			irec = find_inode_rec(mp, XFS_INO_TO_AGNO(mp,
 						mp->m_sb.sb_gquotino),
 				XFS_INO_TO_AGINO(mp, mp->m_sb.sb_gquotino));
+			ASSERT(irec != NULL);
 			offset = XFS_INO_TO_AGINO(mp, mp->m_sb.sb_gquotino)
 					- irec->ino_startnum;
 			add_inode_reached(irec, offset);
@@ -3119,6 +3121,7 @@ mark_standalone_inodes(xfs_mount_t *mp)
 			irec = find_inode_rec(mp, XFS_INO_TO_AGNO(mp,
 						mp->m_sb.sb_pquotino),
 				XFS_INO_TO_AGINO(mp, mp->m_sb.sb_pquotino));
+			ASSERT(irec != NULL);
 			offset = XFS_INO_TO_AGINO(mp, mp->m_sb.sb_pquotino)
 					- irec->ino_startnum;
 			add_inode_reached(irec, offset);
-- 
1.7.9.5

_______________________________________________
xfs mailing list
xfs@xxxxxxxxxxx
http://oss.sgi.com/mailman/listinfo/xfs



[Index of Archives]     [Linux XFS Devel]     [Linux Filesystem Development]     [Filesystem Testing]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux