linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] xfs:xfs_dir2_node.c: pointer use before check for null
@ 2013-10-22  7:36 Denis Efremov
  2013-10-22 20:33 ` Dave Chinner
  0 siblings, 1 reply; 5+ messages in thread
From: Denis Efremov @ 2013-10-22  7:36 UTC (permalink / raw)
  To: Ben Myers; +Cc: Denis Efremov, Alex Elder, xfs, linux-kernel, ldv-project

Reorder of assert and args pointer dereference.

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

Signed-off-by: Denis Efremov <yefremov.denis@gmail.com>
---
 fs/xfs/xfs_dir2_node.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/xfs/xfs_dir2_node.c b/fs/xfs/xfs_dir2_node.c
index 4c3dba7..0ba7382 100644
--- a/fs/xfs/xfs_dir2_node.c
+++ b/fs/xfs/xfs_dir2_node.c
@@ -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) {
-- 
1.8.3.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] xfs:xfs_dir2_node.c: pointer use before check for null
  2013-10-22  7:36 [PATCH] xfs:xfs_dir2_node.c: pointer use before check for null Denis Efremov
@ 2013-10-22 20:33 ` Dave Chinner
  2013-10-25 11:53   ` [PATCH v2] " Denis Efremov
  0 siblings, 1 reply; 5+ messages in thread
From: Dave Chinner @ 2013-10-22 20:33 UTC (permalink / raw)
  To: Denis Efremov; +Cc: Ben Myers, ldv-project, Alex Elder, linux-kernel, xfs

On Tue, Oct 22, 2013 at 11:36:15AM +0400, Denis Efremov wrote:
> Reorder of assert and args pointer dereference.
> 
> Found by Linux Driver Verification project (linuxtesting.org) -
> PVS-Studio analyzer.
> 
> Signed-off-by: Denis Efremov <yefremov.denis@gmail.com>
> ---
>  fs/xfs/xfs_dir2_node.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/fs/xfs/xfs_dir2_node.c b/fs/xfs/xfs_dir2_node.c
> index 4c3dba7..0ba7382 100644
> --- a/fs/xfs/xfs_dir2_node.c
> +++ b/fs/xfs/xfs_dir2_node.c
> @@ -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.
-- 
Dave Chinner
david@fromorbit.com

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH v2] xfs:xfs_dir2_node.c: pointer use before check for null
  2013-10-22 20:33 ` Dave Chinner
@ 2013-10-25 11:53   ` Denis Efremov
  2013-10-25 15:06     ` Ben Myers
  0 siblings, 1 reply; 5+ messages in thread
From: Denis Efremov @ 2013-10-25 11:53 UTC (permalink / raw)
  To: Dave Chinner
  Cc: Denis Efremov, Ben Myers, Alex Elder, xfs, linux-kernel, ldv-project

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.

Signed-off-by: Denis Efremov <yefremov.denis@gmail.com>
---
 fs/xfs/xfs_dir2_node.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/fs/xfs/xfs_dir2_node.c b/fs/xfs/xfs_dir2_node.c
index 4c3dba7..dc814df 100644
--- a/fs/xfs/xfs_dir2_node.c
+++ b/fs/xfs/xfs_dir2_node.c
@@ -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) {
-- 
1.8.3.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH v2] xfs:xfs_dir2_node.c: pointer use before check for null
  2013-10-25 11:53   ` [PATCH v2] " Denis Efremov
@ 2013-10-25 15:06     ` Ben Myers
  2013-10-31 15:56       ` Ben Myers
  0 siblings, 1 reply; 5+ messages in thread
From: Ben Myers @ 2013-10-25 15:06 UTC (permalink / raw)
  To: Denis Efremov; +Cc: Dave Chinner, Alex Elder, xfs, linux-kernel, ldv-project

On Fri, Oct 25, 2013 at 03:53:25PM +0400, Denis Efremov wrote:
> 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.
> 
> Signed-off-by: Denis Efremov <yefremov.denis@gmail.com>

Looks good. 

Reviewed-by: Ben Myers <bpm@sgi.com>

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v2] xfs:xfs_dir2_node.c: pointer use before check for null
  2013-10-25 15:06     ` Ben Myers
@ 2013-10-31 15:56       ` Ben Myers
  0 siblings, 0 replies; 5+ messages in thread
From: Ben Myers @ 2013-10-31 15:56 UTC (permalink / raw)
  To: Denis Efremov; +Cc: ldv-project, Alex Elder, linux-kernel, xfs

On Fri, Oct 25, 2013 at 10:06:09AM -0500, Ben Myers wrote:
> On Fri, Oct 25, 2013 at 03:53:25PM +0400, Denis Efremov wrote:
> > 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.
> > 
> > Signed-off-by: Denis Efremov <yefremov.denis@gmail.com>
> 
> Looks good. 
> 
> Reviewed-by: Ben Myers <bpm@sgi.com>

Applied.  Thanks Denis.

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2013-10-31 15:56 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-10-22  7:36 [PATCH] xfs:xfs_dir2_node.c: pointer use before check for null Denis Efremov
2013-10-22 20:33 ` Dave Chinner
2013-10-25 11:53   ` [PATCH v2] " Denis Efremov
2013-10-25 15:06     ` Ben Myers
2013-10-31 15:56       ` Ben Myers

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).