From: David Chinner <dgc@sgi.com>
Date: Thu, 6 Mar 2008 02:49:43 +0000 (+1100)
Subject: [XFS] fix inode leak in xfs_iget_core()
X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=72772a3b5b158cddcfbbff3ef13b26b03a905158;p=GitHub%2FLineageOS%2FG12%2Fandroid_kernel_amlogic_linux-4.9.git

[XFS] fix inode leak in xfs_iget_core()

If the radix_tree_preload() fails, we need to destroy the inode we just
read in before trying again. This could leak xfs_vnode structures when
there is memory pressure. Noticed by Christoph Hellwig.

SGI-PV: 977823
SGI-Modid: xfs-linux-melb:xfs-kern:30606a

Signed-off-by: David Chinner <dgc@sgi.com>
Signed-off-by: Lachlan McIlroy <lachlan@sgi.com>
Signed-off-by: Christoph Hellwig <hch@infradead.org>
---

diff --git a/fs/xfs/xfs_iget.c b/fs/xfs/xfs_iget.c
index f01b07687faf..8e09b71f4104 100644
--- a/fs/xfs/xfs_iget.c
+++ b/fs/xfs/xfs_iget.c
@@ -235,6 +235,7 @@ finish_inode:
 	 */
 	new_icl = kmem_zone_alloc(xfs_icluster_zone, KM_SLEEP);
 	if (radix_tree_preload(GFP_KERNEL)) {
+		xfs_idestroy(ip);
 		delay(1);
 		goto again;
 	}