All of lore.kernel.org
 help / color / mirror / Atom feed
* [ndctl patch] btt_check_arenas: fix use of uninitialized variable
@ 2017-10-16 19:33 Jeff Moyer
  2017-10-31 19:20 ` Vishal Verma
  0 siblings, 1 reply; 2+ messages in thread
From: Jeff Moyer @ 2017-10-16 19:33 UTC (permalink / raw)
  To: linux-nvdimm, dan.j.williams

Coverity complains that rc, passed to btt_xlat_status, may be
used uninitialized.  In that case, we may also dereference a
NULL pointer.  Fix it by only calling btt_xlat_status with a
valid arena.

Signed-off-by: Jeff Moyer <jmoyer@redhat.com>

diff --git a/ndctl/check.c b/ndctl/check.c
index 915bb9d..93f95c6 100644
--- a/ndctl/check.c
+++ b/ndctl/check.c
@@ -582,9 +582,10 @@ static int btt_check_arenas(struct btt_chk *bttc)
 			break;
 	}
 
-	btt_xlat_status(a, rc);
-	if (rc)
+	if (a && rc != BTT_OK) {
+		btt_xlat_status(a, rc);
 		return -ENXIO;
+	}
 	return 0;
 }
 
_______________________________________________
Linux-nvdimm mailing list
Linux-nvdimm@lists.01.org
https://lists.01.org/mailman/listinfo/linux-nvdimm

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

* Re: [ndctl patch] btt_check_arenas: fix use of uninitialized variable
  2017-10-16 19:33 [ndctl patch] btt_check_arenas: fix use of uninitialized variable Jeff Moyer
@ 2017-10-31 19:20 ` Vishal Verma
  0 siblings, 0 replies; 2+ messages in thread
From: Vishal Verma @ 2017-10-31 19:20 UTC (permalink / raw)
  To: Jeff Moyer; +Cc: linux-nvdimm

On 10/16, Jeff Moyer wrote:
> Coverity complains that rc, passed to btt_xlat_status, may be
> used uninitialized.  In that case, we may also dereference a
> NULL pointer.  Fix it by only calling btt_xlat_status with a
> valid arena.
> 
> Signed-off-by: Jeff Moyer <jmoyer@redhat.com>

Good catch!
Reviewed-by: Vishal Verma <vishal.l.verma@intel.com>
> 
> diff --git a/ndctl/check.c b/ndctl/check.c
> index 915bb9d..93f95c6 100644
> --- a/ndctl/check.c
> +++ b/ndctl/check.c
> @@ -582,9 +582,10 @@ static int btt_check_arenas(struct btt_chk *bttc)
>  			break;
>  	}
>  
> -	btt_xlat_status(a, rc);
> -	if (rc)
> +	if (a && rc != BTT_OK) {
> +		btt_xlat_status(a, rc);
>  		return -ENXIO;
> +	}
>  	return 0;
>  }
>  
> _______________________________________________
> Linux-nvdimm mailing list
> Linux-nvdimm@lists.01.org
> https://lists.01.org/mailman/listinfo/linux-nvdimm
_______________________________________________
Linux-nvdimm mailing list
Linux-nvdimm@lists.01.org
https://lists.01.org/mailman/listinfo/linux-nvdimm

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

end of thread, other threads:[~2017-10-31 19:18 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-10-16 19:33 [ndctl patch] btt_check_arenas: fix use of uninitialized variable Jeff Moyer
2017-10-31 19:20 ` Vishal Verma

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.