fs/ntfs3: Add check for kmemdup
authorJiasheng Jiang <jiasheng@iscas.ac.cn>
Wed, 23 Nov 2022 08:48:46 +0000 (16:48 +0800)
committerKonstantin Komarov <almaz.alexandrovich@paragon-software.com>
Mon, 27 Mar 2023 12:59:08 +0000 (16:59 +0400)
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>
fs/ntfs3/fslog.c

index c6eb371a36951bd1fc776ee0e97b5e171daa9c77..dc723f03d6bb202d7c19dba149c3330b23b6d931 100644 (file)
@@ -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;