fs/ntfs3: Avoid possible memory leak
authorSu Hui <suhui@nfschina.com>
Mon, 25 Sep 2023 04:48:07 +0000 (12:48 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 8 Nov 2023 13:10:59 +0000 (14:10 +0100)
[ Upstream commit e4494770a5cad3c9d1d2a65ed15d07656c0d9b82 ]

smatch warn:
fs/ntfs3/fslog.c:2172 last_log_lsn() warn: possible memory leak of 'page_bufs'
Jump to label 'out' to free 'page_bufs' and is more consistent with
other code.

Signed-off-by: Su Hui <suhui@nfschina.com>
Signed-off-by: Konstantin Komarov <almaz.alexandrovich@paragon-software.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
fs/ntfs3/fslog.c

index 00faf41d8f97d9b821067c019895113d0b69fe5f..710cb5aa5a65b0cce8817d12273c0c1f30668b15 100644 (file)
@@ -2169,8 +2169,10 @@ file_is_valid:
 
                        if (!page) {
                                page = kmalloc(log->page_size, GFP_NOFS);
-                               if (!page)
-                                       return -ENOMEM;
+                               if (!page) {
+                                       err = -ENOMEM;
+                                       goto out;
+                               }
                        }
 
                        /*