Skip to content

Commit

Permalink
fs/ntfs3: Add check for kmemdup
Browse files Browse the repository at this point in the history
[ Upstream commit e6c3cef ]

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: b46acd6 ("fs/ntfs3: Add NTFS journal")
Signed-off-by: Jiasheng Jiang <jiasheng@iscas.ac.cn>
Signed-off-by: Konstantin Komarov <almaz.alexandrovich@paragon-software.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
  • Loading branch information
JiangJias authored and gregkh committed May 11, 2023
1 parent 3bb0d3e commit cdcdfd5
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions fs/ntfs3/fslog.c
Original file line number Diff line number Diff line change
Expand Up @@ -4256,6 +4256,10 @@ int log_replay(struct ntfs_inode *ni, bool *initialized)
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;
Expand Down

0 comments on commit cdcdfd5

Please sign in to comment.