Skip to contentSkip to conversation

xfsprogs: fix potential memory leak in repare/sb.c

PATCH In review Li Zhong 3 participants 3 messages Sep 18, 2013 – Oct 18, 2013

lore
Share & tools
lore

Li Zhong

author
#0 lore raw

PATCH 1/1 xfsprogs: fix potential memory leak in repare/sb.c

Following Resource leak is reported by coverity:

CID 997011 (#1 of 1): Resource leak (RESOURCE_LEAK)6. leaked_storage:
Variable "buf" going out of scope leaks the storage it points to.
505 return(XR_EOF);

Add a free(buf) to solve it.

---
 repair/sb.c | 1 +
 1 file changed, 1 insertion(+)
repair/sb.c +1 -0
index e2f5933..aa550e3 100644
@@ -502,6 +502,7 @@ get_sb(xfs_sb_t *sbp, xfs_off_t off, int size, xfs_agnumber_t agno)
 		do_warn(
 	_("error reading superblock %u -- seek to offset %" PRId64 " failed\n"),
 			agno, off);
+		free(buf);
 		return(XR_EOF);
 	}
 

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs

Reviewed-by on v1 1/1
#1 lore raw
Quoted 10 lines · Li Zhong

Following Resource leak is reported by coverity:

CID 997011 (#1 of 1): Resource leak (RESOURCE_LEAK)6. leaked_storage:
Variable "buf" going out of scope leaks the storage it points to.
505 return(XR_EOF);

Add a free(buf) to solve it.

---

Looks good.

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs