All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/3] xfs_repair: fix some potential null pointer deferences
@ 2016-12-15 18:11 Darrick J. Wong
  2016-12-15 18:11 ` [PATCH 2/3] xfs_repair: fix bogus rmapbt record owner check Darrick J. Wong
                   ` (3 more replies)
  0 siblings, 4 replies; 12+ messages in thread
From: Darrick J. Wong @ 2016-12-15 18:11 UTC (permalink / raw)
  To: sandeen, darrick.wong; +Cc: linux-xfs

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_ */


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

end of thread, other threads:[~2016-12-21  4:26 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-12-15 18:11 [PATCH 1/3] xfs_repair: fix some potential null pointer deferences Darrick J. Wong
2016-12-15 18:11 ` [PATCH 2/3] xfs_repair: fix bogus rmapbt record owner check Darrick J. Wong
2016-12-15 19:20   ` Eric Sandeen
2016-12-15 18:11 ` [PATCH 3/3] xfs_io: fix the minimum arguments to the reflink command Darrick J. Wong
2016-12-15 18:38   ` Eric Sandeen
2016-12-16  0:51     ` Darrick J. Wong
2016-12-21  4:24   ` Eric Sandeen
2016-12-15 23:17 ` [PATCH 1/3] xfs_repair: fix some potential null pointer deferences Eric Sandeen
2016-12-16  0:58   ` Darrick J. Wong
2016-12-16  1:39     ` Eric Sandeen
2016-12-16  0:52 ` [PATCH 4/3] xfs_io: fix some documentation problems Darrick J. Wong
2016-12-21  4:26   ` Eric Sandeen

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.