Skip to contentSkip to conversation

repair: fix an uninitialized variable issue

PATCH In review Gao Xiang 3 participants 3 messages Apr 21, 2021

lore
Share & tools
lore

Gao Xiang

author
#0 lore raw

PATCH 1/1 repair: fix an uninitialized variable issue

An uninitialized variable issue reported by Coverity, it seems the following for-loop can be exited in advance with isblock == 1, and bp is still uninitialized.

In case of that, initialize bp as NULL in advance to avoid this.

Fixes 1f7c7553489c ("repair: don't duplicate names in phase 6")
---
 repair/phase6.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
repair/phase6.c +1 -1
index 72287b5c..6bddfefa 100644
@@ -2195,7 +2195,7 @@ longform_dir2_entry_check(
 	int			ino_offset,
 	struct dir_hash_tab	*hashtab)
 {
-	struct xfs_buf		*bp;
+	struct xfs_buf		*bp = NULL;
 	xfs_dablk_t		da_bno;
 	freetab_t		*freetab;
 	int			i;
Signature · 1 line
2.27.0
Reviewed-by on v1 1/1
#1 lore raw
Quoted 1 line · Gao Xiang

An uninitialized variable issue reported by Coverity, it seems

Minor nit: we often include the coverity id for things it finds. Links to a semi-private corporate bug tracker aren't necessarily generally useful, but I guess they did find a legit bug so we could throw them one crumb.

Quoted 7 lines

the following for-loop can be exited in advance with isblock == 1, and bp is still uninitialized.

In case of that, initialize bp as NULL in advance to avoid this.

Fixes 1f7c7553489c ("repair: don't duplicate names in phase 6")

Either way, it's not worth holding up this patch, so:

--D

Quoted 20 lines
---
 repair/phase6.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
repair/phase6.c +1 -1
index 72287b5c..6bddfefa 100644
@@ -2195,7 +2195,7 @@ longform_dir2_entry_check(
 	int			ino_offset,
 	struct dir_hash_tab	*hashtab)
 {
-	struct xfs_buf		*bp;
+	struct xfs_buf		*bp = NULL;
 	xfs_dablk_t		da_bno;
 	freetab_t		*freetab;
 	int			i;
Signature · 1 line
2.27.0
#2 lore raw
Quoted 11 lines · Darrick J. Wong
Quoted 1 line · Gao Xiang

An uninitialized variable issue reported by Coverity, it seems

Minor nit: we often include the coverity id for things it finds. Links to a semi-private corporate bug tracker aren't necessarily generally useful, but I guess they did find a legit bug so we could throw them one crumb.

Quoted 3 lines

the following for-loop can be exited in advance with isblock == 1, and bp is still uninitialized.

Quoted 8 lines
Quoted 4 lines

In case of that, initialize bp as NULL in advance to avoid this.

Fixes 1f7c7553489c ("repair: don't duplicate names in phase 6")

Either way, it's not worth holding up this patch, so:

Thanks Darrick and Gao. Easy enough for me to add the coverity ID on commit.

-Eric