Message ID | x49376ikhuy.fsf@segfault.boston.devel.redhat.com (mailing list archive) |
---|---|
State | Accepted |
Commit | 68dc64b17a63 |
Headers | show |
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
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; }
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>