]> www.infradead.org Git - users/hch/xfsprogs.git/commit
xfs_db: release ip resource before returning from get_next_unlinked()
authorBill O'Donnell <bodonnel@redhat.com>
Fri, 9 Aug 2024 17:15:42 +0000 (12:15 -0500)
committerCarlos Maiolino <cem@kernel.org>
Mon, 16 Sep 2024 07:11:28 +0000 (09:11 +0200)
commit2f0fedf94c54937662df6a95b7765f8745f39e2c
tree8fcb3e5f7314f4b1dc789a95f234a8044a3c918f
parent71d2969be616e79bcfaa2d27414337afde40cdfc
xfs_db: release ip resource before returning from get_next_unlinked()

Fix potential memory leak in function get_next_unlinked(). Call
libxfs_irele(ip) before exiting.

Details:
Error: RESOURCE_LEAK (CWE-772):
xfsprogs-6.5.0/db/iunlink.c:51:2: alloc_arg: "libxfs_iget" allocates memory that is stored into "ip".
xfsprogs-6.5.0/db/iunlink.c:68:2: noescape: Resource "&ip->i_imap" is not freed or pointed-to in "libxfs_imap_to_bp".
xfsprogs-6.5.0/db/iunlink.c:76:2: leaked_storage: Variable "ip" going out of scope leaks the storage it points to.
#   74|    libxfs_buf_relse(ino_bp);
#   75|
#   76|->  return ret;
#   77|   bad:
#   78|    dbprintf(_("AG %u agino %u: %s\n"), agno, agino, strerror(error));

Signed-off-by: Bill O'Donnell <bodonnel@redhat.com>
Reviewed-by: Eric Sandeen <sandeen@redhat.com>
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
db/iunlink.c