[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <0bf7a140-1405-2b07-4d29-d593d9507c33@paragon-software.com>
Date: Mon, 26 Dec 2022 19:04:35 +0400
From: Konstantin Komarov <almaz.alexandrovich@...agon-software.com>
To: Jiasheng Jiang <jiasheng@...as.ac.cn>, <nathan@...nel.org>,
<ndesaulniers@...gle.com>, <trix@...hat.com>
CC: <ntfs3@...ts.linux.dev>, <linux-kernel@...r.kernel.org>,
<llvm@...ts.linux.dev>
Subject: Re: [PATCH] fs/ntfs3: Add check for kmemdup
On 23.11.2022 12:48, Jiasheng Jiang wrote:
> 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@...as.ac.cn>
> ---
> fs/ntfs3/fslog.c | 4 ++++
> 1 file changed, 4 insertions(+)
>
> diff --git a/fs/ntfs3/fslog.c b/fs/ntfs3/fslog.c
> index 0d611a6c5511..eb7cf8a69607 100644
> --- a/fs/ntfs3/fslog.c
> +++ b/fs/ntfs3/fslog.c
> @@ -4277,6 +4277,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;
Thank you for your work, applied!
Powered by blists - more mailing lists