From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id ED8CF168AD for ; Mon, 8 May 2023 10:13:51 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 632E4C433EF; Mon, 8 May 2023 10:13:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1683540831; bh=ncgCHf0XIjs14Hqnabp2mTU6YZYpVjvUsIXcB1qRjcg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=rB/jgPAZNagGVsZcEMx7ShjDhOfwGqW/kd3X2Z5r8/zgD6KCXC8RzcvjmYPL/yJ1U mRTYFinupc51YRCTTDPxzsGwh3uqIF0oNuNL1yRfHNL/lHOh9E4lVA/utTMUQnR+GY qye09ozDC2bAFkPzMN0WVWsyJkkNK0LGstsS5Xfs= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Jiasheng Jiang , Konstantin Komarov , Sasha Levin Subject: [PATCH 6.1 487/611] fs/ntfs3: Add check for kmemdup Date: Mon, 8 May 2023 11:45:29 +0200 Message-Id: <20230508094437.900976061@linuxfoundation.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230508094421.513073170@linuxfoundation.org> References: <20230508094421.513073170@linuxfoundation.org> User-Agent: quilt/0.67 Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit From: Jiasheng Jiang [ Upstream commit e6c3cef24cb0d045f99d5cb039b344874e3cfd74 ] 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 Signed-off-by: Konstantin Komarov Signed-off-by: Sasha Levin --- fs/ntfs3/fslog.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/fs/ntfs3/fslog.c b/fs/ntfs3/fslog.c index c662d2a519072..422057df8691f 100644 --- a/fs/ntfs3/fslog.c +++ b/fs/ntfs3/fslog.c @@ -4258,6 +4258,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; -- 2.39.2