From: Colin Ian King Date: Fri, 10 Sep 2021 10:02:02 +0000 (+0100) Subject: fs/ntfs3: Fix a memory leak on object opts X-Git-Url: http://git.maquefel.me/?a=commitdiff_plain;h=880301bb313295a65523e79bc5666f5cf49eb3ed;p=linux.git fs/ntfs3: Fix a memory leak on object opts Currently a failed allocation on sbi->upcase will cause an exit via the label free_sbi causing a memory leak on object opts. Fix this by re-ordering the exit paths free_opts and free_sbi so that kfree's occur in the reverse allocation order. Addresses-Coverity: ("Resource leak") Fixes: 27fac77707a1 ("fs/ntfs3: Init spi more in init_fs_context than fill_super") Signed-off-by: Colin Ian King Reviewed-by: Kari Argillander Signed-off-by: Konstantin Komarov --- diff --git a/fs/ntfs3/super.c b/fs/ntfs3/super.c index cefb9ddaf4db7..6a535b144ff96 100644 --- a/fs/ntfs3/super.c +++ b/fs/ntfs3/super.c @@ -1393,10 +1393,10 @@ ok: fc->ops = &ntfs_context_ops; return 0; -free_opts: - kfree(opts); free_sbi: kfree(sbi); +free_opts: + kfree(opts); return -ENOMEM; }