All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Darrick J. Wong" <darrick.wong@oracle.com>
To: david@fromorbit.com, darrick.wong@oracle.com
Cc: linux-xfs@vger.kernel.org
Subject: [PATCH 01/11] xfs_repair: fix some potential null pointer deferences
Date: Fri, 04 Nov 2016 11:30:11 -0700	[thread overview]
Message-ID: <147828421174.31492.258418976731027281.stgit@birch.djwong.org> (raw)
In-Reply-To: <147828420554.31492.4173929442743951581.stgit@birch.djwong.org>

Fix some potential NULL pointer deferences that Coverity pointed out,
and remove a trivial dead integer check.

Coverity-id: 1375789, 1375790, 1375791, 1375792
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
---
 repair/phase5.c |    2 +-
 repair/rmap.c   |    2 +-
 repair/slab.h   |    2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)


diff --git a/repair/phase5.c b/repair/phase5.c
index 3604d1d..cbda556 100644
--- a/repair/phase5.c
+++ b/repair/phase5.c
@@ -1925,7 +1925,7 @@ _("Insufficient memory to construct refcount cursor."));
 	refc_rec = pop_slab_cursor(refc_cur);
 	lptr = &btree_curs->level[0];
 
-	for (i = 0; i < lptr->num_blocks; i++)  {
+	for (i = 0; i < lptr->num_blocks && refc_rec != NULL; i++)  {
 		/*
 		 * block initialization, lay in block header
 		 */
diff --git a/repair/rmap.c b/repair/rmap.c
index 45e183a..7508973 100644
--- a/repair/rmap.c
+++ b/repair/rmap.c
@@ -790,7 +790,7 @@ compute_refcounts(
 		mark_inode_rl(mp, stack_top);
 
 		/* Set nbno to the bno of the next refcount change */
-		if (n < slab_count(rmaps))
+		if (n < slab_count(rmaps) && array_cur)
 			nbno = array_cur->rm_startblock;
 		else
 			nbno = NULLAGBLOCK;
diff --git a/repair/slab.h b/repair/slab.h
index 4aa5512..a2201f1 100644
--- a/repair/slab.h
+++ b/repair/slab.h
@@ -54,7 +54,7 @@ extern void *bag_item(struct xfs_bag *, size_t);
 
 #define foreach_bag_ptr_reverse(bag, idx, ptr) \
 	for ((idx) = bag_count(bag) - 1, (ptr) = bag_item((bag), (idx)); \
-	     (idx) >= 0 && (ptr) != NULL; \
+	     (ptr) != NULL; \
 	     (idx)--, (ptr) = bag_item((bag), (idx)))
 
 #endif /* SLAB_H_ */


  reply	other threads:[~2016-11-04 18:30 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-11-04 18:30 [PATCH 00/11] xfsprogs: miscellaneous libxfs cleanups Darrick J. Wong
2016-11-04 18:30 ` Darrick J. Wong [this message]
2016-11-04 18:30 ` [PATCH 02/11] xfs_repair: fix bogus rmapbt record owner check Darrick J. Wong
2016-11-04 18:30 ` [PATCH 03/11] xfs_io: fix libxfs naming violation Darrick J. Wong
2016-11-04 18:30 ` [PATCH 04/11] libxfs: remove unnecessary hascrc test in btree verifiers Darrick J. Wong
2016-11-04 18:30 ` [PATCH 05/11] xfs: set XFS_DA_OP_OKNOENT in xfs_attr_get Eric Sandeen
2016-11-06 22:20   ` Dave Chinner
2016-11-04 18:30 ` [PATCH 06/11] libxfs: refactor btree crc verifier Darrick J. Wong
2016-11-04 18:30 ` [PATCH 07/11] libxfs: fix whitespace to match the kernel Darrick J. Wong
2016-11-04 18:30 ` [PATCH 08/11] libxfs: return bool from sb_version_hasmetauuid Darrick J. Wong
2016-11-04 18:31 ` [PATCH 09/11] xfs: fix btree cursor error cleanups Brian Foster
2016-11-04 18:31 ` [PATCH 10/11] libxfs: clean up _dir2_data_freescan Darrick J. Wong
2016-11-04 18:31 ` [PATCH 11/11] tools: create libxfs-diff to compare libxfses Darrick J. Wong

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=147828421174.31492.258418976731027281.stgit@birch.djwong.org \
    --to=darrick.wong@oracle.com \
    --cc=david@fromorbit.com \
    --cc=linux-xfs@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.