From nobody Sun Feb 8 12:52:14 2026 Received: from mail-ot1-f41.google.com (mail-ot1-f41.google.com [209.85.210.41]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B9768286416 for ; Sat, 17 Jan 2026 18:59:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.41 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768676356; cv=none; b=IKx2XKeNMvYTyr5yqxyRcBeOss11L5kTV6rzYSBeJ3H10UDv32Mkn7xhmjeN8G8mOV4qxcS91xwfTUzDY+Flh8AxyurE9/cT74QN/w82ObPFVPBKp1DRVDZz2/Cl/vAEbJVvtRaqlttng0/xP1IorkKs04w/v1phBuFDyuXRmpk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768676356; c=relaxed/simple; bh=oEuW/QLl6h804oriTctKWM2AkhAEUaiwfgMyD8azYw4=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=ooFyHoY1zv8rNLDX3nuyjv8FC4huLDeGFWz8uWJ78dM0MkX/qhlAho996jJrEWPq2e0JZLdPhAp8UEzp4aQKuSiXutAxNrPg5flIenE9F+k/ZRlTuVxYYkUWI8+Kbxz8GtV00tCkXnL9LCHQ6Z75dv4sIDaHKUrdenYiA7VlkNU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=QDGK0wkt; arc=none smtp.client-ip=209.85.210.41 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="QDGK0wkt" Received: by mail-ot1-f41.google.com with SMTP id 46e09a7af769-7cfdcae466eso1602748a34.3 for ; Sat, 17 Jan 2026 10:59:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1768676353; x=1769281153; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=hJZfCNDTWwJxFhoFMagUMWswNzWJPKtcKs8+XIrwaVo=; b=QDGK0wkta3HCmzlJjJdqN9Q2meetGC66ioYqvzzJD0rfKwi0STzL+tD/Zp4+MFqT+k yPwG13TdnebNB2M8FOoVdQplK8BWT9BWrgOBd0zuvSJN2WFj78qzHh+2qs25IbKanxA5 Vd5v2UpA45jKVS+M7AyKLhbq27MtqnzKBazyqxVL1/WgLWLmWKGpXsYXfUpzG7EifJw9 d0DU6AxOQ9dkp0SA5bUXyovl4QzqU0BHKV1LVxhN5g0pokVJRnQdf8gs+Thdy24vqaMt AcB1WerQ5ui+Pl+0dWYHzChKHTQqM7817mpfXNyOsuUUt0PW7iD0h63eA1/zJolvJZa4 JDKw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1768676353; x=1769281153; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=hJZfCNDTWwJxFhoFMagUMWswNzWJPKtcKs8+XIrwaVo=; b=OE+oHDStQd6TEWXB54eyxsOsKLEFMna5n/JPcYKM8SdSIB9Ondy4gejCmLPU7GVt9z y2RF5FlJED6KzMBq+nmz0VELU1VR3SHKFEedZqqjtH65l90ZI+PfZyXAZ6f+XLpnnC16 DpqtEgMcBa0OZgttbJRfHzXTkyrXrjuXbke4GAuNaQXcHU+6gD1Xf3lyH/ct8Qy/UU3i ATUjSs7jFryzMG4/6mAjIfVeUZF5UxTEriOo5Jjl9ujjWdxnScs4TPuV3s/3n7w1JEyp OA85EWn/AnBsePMHKnpSn2b5OPbPkVA+0aDyQLzQNPFUg/MnPd1+o0MANbu/WpW/TiAh q5Kw== X-Forwarded-Encrypted: i=1; AJvYcCVT/Box6vo/YuRtPgzausSLxjODFYF8amm6KDaloA/JRcV0ADNO6i8c3bC+Zj2DR5NJOU9paKCjcDILEsw=@vger.kernel.org X-Gm-Message-State: AOJu0Yz9RpQ9MgBzVxKYabzOT6mNrAXkhjgqhow9Sd7w4wlRuJK3QzWS FsMHd5nEEAGdLZXy22z1uP8kpaEAohr903QgApCT4vQVNacjJY37s9unfeR86Q== X-Gm-Gg: AY/fxX7XObZKADYguGZV558M4kA4Rp0qRwZ+dmkzQE9EeYgmXyJROF9hRVQ3Hvk21w0 8YquFtWt2TDErRwBl88YSuCQT9BQBjZoGXMDL8ERnJgXGnreY50+pPuVXNoXrsAjo53VQ7rrcjp fr1gtBNKYPO35g65SmTUFtVLIiHiTHFDJuNx60JPPA9Y8FTZWnfQMh5QaGR0UHnH942un1yNVkV P2naKl32EnDfdxXly4CXkO1GPs1s5wjRvSdVtNT2LGrHvVgQLnUrWr53KigKH1Sd4vzbm9UW8SG iuAyckQhzYcU32ZFRylFWog/9XngczGOouQFp9uIpEQJ073UqrR+qu0WE/MrqUZS/i7s2Hzf1P+ zeSCir4a882qaLUdtyHy82Xpjof34PRvGllhNjxpzlQ6F4MvYcCBv2wl/2ERAwfRoH9FbeqnA5x z0eSWyMSVqGLhTtDDWbxVEXFVT5bKKmPia X-Received: by 2002:a05:6830:82e4:b0:7cf:d0b4:bab7 with SMTP id 46e09a7af769-7cfdee8f50emr4258117a34.34.1768676353553; Sat, 17 Jan 2026 10:59:13 -0800 (PST) Received: from newman.cs.purdue.edu ([128.10.127.250]) by smtp.gmail.com with ESMTPSA id 46e09a7af769-7cfdf2b5aaesm4016486a34.31.2026.01.17.10.59.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 17 Jan 2026 10:59:13 -0800 (PST) From: Jiasheng Jiang To: Konstantin Komarov , linux-kernel@vger.kernel.org Cc: ntfs3@lists.linux.dev, Jiasheng Jiang Subject: [PATCH] fs/ntfs3: Fix memory and resource leak in indx_find_sort Date: Sat, 17 Jan 2026 18:59:11 +0000 Message-Id: <20260117185911.39415-1-jiashengjiangcool@gmail.com> X-Mailer: git-send-email 2.25.1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The function indx_find_sort() incorrectly uses kfree(n) to cleanup the 'struct indx_node' instance in error paths. The 'struct indx_node' is a container that manages internal allocations (n->index) and holds a reference to a buffer head (n->nb). Using kfree() directly on the node pointer only frees the container itself, resulting in a memory leak of the index buffer and a resource leak of the buffer head reference. This patch replaces the incorrect kfree(n) calls with the specialized helper put_indx_node(n), which correctly releases the internal resources and the buffer head, consistent with other functions like indx_find_raw(). Signed-off-by: Jiasheng Jiang --- fs/ntfs3/index.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/fs/ntfs3/index.c b/fs/ntfs3/index.c index 7157cfd70fdc..c598b4b2f454 100644 --- a/fs/ntfs3/index.c +++ b/fs/ntfs3/index.c @@ -1248,7 +1248,7 @@ int indx_find_sort(struct ntfs_index *indx, struct nt= fs_inode *ni, sizeof(struct NTFS_DE) + sizeof(u64)) { if (n) { fnd_pop(fnd); - kfree(n); + put_indx_node(n); } return -EINVAL; } @@ -1261,7 +1261,7 @@ int indx_find_sort(struct ntfs_index *indx, struct nt= fs_inode *ni, /* Try next level. */ e =3D hdr_first_de(&n->index->ihdr); if (!e) { - kfree(n); + put_indx_node(n); return -EINVAL; } =20 @@ -1281,7 +1281,7 @@ int indx_find_sort(struct ntfs_index *indx, struct nt= fs_inode *ni, /* Pop one level. */ if (n) { fnd_pop(fnd); - kfree(n); + put_indx_node(n); } =20 level =3D fnd->level; --=20 2.25.1