diff options
author | Jiasheng Jiang <jiasheng@iscas.ac.cn> | 2022-11-23 09:48:46 +0100 |
---|---|---|
committer | Konstantin Komarov <almaz.alexandrovich@paragon-software.com> | 2023-03-27 14:59:08 +0200 |
commit | e6c3cef24cb0d045f99d5cb039b344874e3cfd74 (patch) | |
tree | c162f364cfd5836d7d8f78ddd4157739727354e1 /fs/ntfs3 | |
parent | fs/ntfs3: Fix memory leak if ntfs_read_mft failed (diff) | |
download | linux-e6c3cef24cb0d045f99d5cb039b344874e3cfd74.tar.xz linux-e6c3cef24cb0d045f99d5cb039b344874e3cfd74.zip |
fs/ntfs3: Add check for kmemdup
Since the kmemdup may return NULL pointer,
it should be better to add check for the return value
in order to avoid NULL pointer dereference.
Fixes: b46acd6a6a62 ("fs/ntfs3: Add NTFS journal")
Signed-off-by: Jiasheng Jiang <jiasheng@iscas.ac.cn>
Signed-off-by: Konstantin Komarov <almaz.alexandrovich@paragon-software.com>
Diffstat (limited to 'fs/ntfs3')
-rw-r--r-- | fs/ntfs3/fslog.c | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/fs/ntfs3/fslog.c b/fs/ntfs3/fslog.c index c6eb371a3695..dc723f03d6bb 100644 --- a/fs/ntfs3/fslog.c +++ b/fs/ntfs3/fslog.c @@ -4256,6 +4256,10 @@ check_attribute_names: rec_len -= t32; attr_names = kmemdup(Add2Ptr(lrh, t32), rec_len, GFP_NOFS); + if (!attr_names) { + err = -ENOMEM; + goto out; + } lcb_put(lcb); lcb = NULL; |