Skip to contentSkip to conversation

libgfs2: Check rgd->bits before referencing it

PATCH New Bob Peterson 2 participants 2 messages Sep 14, 2015 – Sep 16, 2015 1 message not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

#1 lore raw

PATCH 1/1 libgfs2: Check rgd->bits before referencing it

Hi,

This patch adds a check to function gfs2_rgrp_free to make sure rgd->bits is non-zero before attempting to reference it. This might be NULL because no buffers actually existed because it was concocted in an attempt to repair damaged rgrps in fsck.

Regards,

Bob Peterson
Red Hat File Systems

---

gfs2/libgfs2/rgrp.c +1 -1
index cf4385a..2a55523 100644
@@ -244,7 +244,7 @@ void gfs2_rgrp_free(struct osi_root *rgrp_tree)
 	while ((n = osi_first(rgrp_tree))) {
 		rgd = (struct rgrp_tree *)n;
 
-		if (rgd->bits[0].bi_bh) { /* if a buffer exists */
+		if (rgd->bits && rgd->bits[0].bi_bh) { /* if a buffer exists */
 			rgs_since_sync++;
 			if (rgs_since_sync >= RG_SYNC_TOLERANCE) {
 				if (!sdp)
#2 lore raw

PATCH 1/1 libgfs2: Check rgd->bits before referencing it

Quoted 20 lines · Bob Peterson

Hi,

This patch adds a check to function gfs2_rgrp_free to make sure rgd->bits is non-zero before attempting to reference it. This might be NULL because no buffers actually existed because it was concocted in an attempt to repair damaged rgrps in fsck.

Regards,

Bob Peterson
Red Hat File Systems

---

gfs2/libgfs2/rgrp.c +0 -0
index cf4385a..2a55523 100644

gfs2/libgfs2/rgrp.c void gfs2_rgrp_free(struct osi_root *rgrp_tree) · line 250

Quoted 8 lines
gfs2/libgfs2/rgrp.c +1 -1
@@ -244,7 +244,7 @@ void gfs2_rgrp_free(struct osi_root *rgrp_tree)
  	while ((n = osi_first(rgrp_tree))) {
  		rgd = (struct rgrp_tree *)n;
 
-		if (rgd->bits[0].bi_bh) { /* if a buffer exists */
+		if (rgd->bits && rgd->bits[0].bi_bh) { /* if a buffer exists */
  			rgs_since_sync++;
  			if (rgs_since_sync >= RG_SYNC_TOLERANCE) {
  				if (!sdp)

ACK,

Andy