Skip to contentSkip to conversation

xfs:xfs_dir2_node.c: pointer use before check for null

PATCH Superseded Denis Efremov 3 participants 5 messages Oct 22, 2013 – Oct 31, 2013 XFS filesystem

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 xfs:xfs_dir2_node.c: pointer use before check for null

Reorder of assert and args pointer dereference.

Found by Linux Driver Verification project (linuxtesting.org) - PVS-Studio analyzer.

---
 fs/xfs/xfs_dir2_node.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/xfs/xfs_dir2_node.c +1 -1
index 4c3dba7..0ba7382 100644
@@ -1365,8 +1365,8 @@ xfs_dir2_leafn_split(
 	 * Allocate space for a new leaf node.
 	 */
 	args = state->args;
-	mp = args->dp->i_mount;
 	ASSERT(args != NULL);
+	mp = args->dp->i_mount;
 	ASSERT(oldblk->magic == XFS_DIR2_LEAFN_MAGIC);
 	error = xfs_da_grow_inode(args, &blkno);
 	if (error) {
Signature · 1 line
1.8.3.1
#1 lore raw
Quoted 15 lines · Denis Efremov

Reorder of assert and args pointer dereference.

Found by Linux Driver Verification project (linuxtesting.org) - PVS-Studio analyzer.

---
 fs/xfs/xfs_dir2_node.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/xfs/xfs_dir2_node.c +0 -0
index 4c3dba7..0ba7382 100644

fs/xfs/xfs_dir2_node.c xfs_dir2_leafn_split( · line 1369

Quoted 6 lines
fs/xfs/xfs_dir2_node.c +1 -1
@@ -1365,8 +1365,8 @@ xfs_dir2_leafn_split(
 	 * Allocate space for a new leaf node.
 	 */
 	args = state->args;
-	mp = args->dp->i_mount;
 	ASSERT(args != NULL);
+	mp = args->dp->i_mount;

Just remove the ASSERT. Either way we are going to panic.

Cheers,

Dave.

Signature · 2 lines
Dave Chinner
[email protected]
#2 lore raw

PATCH v2 1/1 xfs:xfs_dir2_node.c: pointer use before check for null

ASSERT on args takes place after args dereference. This assertion is redundant since we are going to panic anyway.

Found by Linux Driver Verification project (linuxtesting.org) - PVS-Studio analyzer.

---
 fs/xfs/xfs_dir2_node.c | 1 -
 1 file changed, 1 deletion(-)
fs/xfs/xfs_dir2_node.c +0 -1
index 4c3dba7..dc814df 100644
@@ -1366,7 +1366,6 @@ xfs_dir2_leafn_split(
 	 */
 	args = state->args;
 	mp = args->dp->i_mount;
-	ASSERT(args != NULL);
 	ASSERT(oldblk->magic == XFS_DIR2_LEAFN_MAGIC);
 	error = xfs_da_grow_inode(args, &blkno);
 	if (error) {
Signature · 1 line
1.8.3.1
Reviewed-by on v2 1/1
#3 lore raw
Quoted 7 lines · Denis Efremov

ASSERT on args takes place after args dereference. This assertion is redundant since we are going to panic anyway.

Found by Linux Driver Verification project (linuxtesting.org) - PVS-Studio analyzer.

Looks good.

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs

Applied
#4 lore raw
Quoted 4 lines · Ben Myers
Quoted 3 lines · Denis Efremov

ASSERT on args takes place after args dereference. This assertion is redundant since we are going to panic anyway.

Quoted 8 lines
Quoted 4 lines

Found by Linux Driver Verification project (linuxtesting.org) - PVS-Studio analyzer.

Looks good.

Applied. Thanks Denis.

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs