In the Linux kernel, the following vulnerability has been resolved: fs/ntfs3: Fix memory leak if ntfsreadmft failed Label ATTRROOT in ntfsreadmft() sets isroot = true and ni->niflags |= NIFLAGDIR, then next attr will goto label ATTRALLOC and alloc ni->dir.allocrun. However two states are not always consistent and can make memory leak. 1) attrname in ATTRROOT does not fit the condition it will set isroot = true but NIFLAGDIR is not set. 2) next attrname in ATTRALLOC fits the condition and alloc ni->dir.allocrun 3) in cleanup function niclear(), when NIFLAGDIR is set, it frees ni->dir.allocrun, otherwise it frees ni->file.run 4) because NIFLAGDIR is not set in this case, ni->dir.allocrun is leaked as kmemleak reported: unreferenced object 0xffff888003bc5480 (size 64): backtrace: [<000000003d42e6b0>] _kmallocnode+0x4e/0x1c0 [<00000000d8e19b8a>] kvmallocnode+0x39/0x1f0 [<00000000fc3eb5b8>] runaddentry+0x18a/0xa40 [ntfs3] [<0000000011c9f978>] rununpack+0x75d/0x8e0 [ntfs3] [<00000000e7cf1819>] rununpackex+0xbc/0x500 [ntfs3] [<00000000bbf0a43d>] ntfsiget5+0xb25/0x2dd0 [ntfs3] [<00000000a6e50693>] ntfsfillsuper+0x218d/0x3580 [ntfs3] [<00000000b9170608>] gettreebdev+0x3fb/0x710 [<000000004833798a>] vfsgettree+0x8e/0x280 [<000000006e20b8e6>] pathmount+0xf3c/0x1930 [<000000007bf15a5f>] domount+0xf3/0x110 ... Fix this by always setting isroot and NIFLAGDIR together.