Received: by 2002:a05:6358:f14:b0:e5:3b68:ec04 with SMTP id b20csp3705102rwj; Tue, 20 Dec 2022 00:18:14 -0800 (PST) X-Google-Smtp-Source: AMrXdXtK+4wUzHKxz+WSSKwYP2H3id3/cX3F5iJYhoOjOQTMYIeHXF3C/xr97eylGW5+MRRzznsm X-Received: by 2002:a05:6a00:1da5:b0:576:5a71:454a with SMTP id z37-20020a056a001da500b005765a71454amr8835452pfw.2.1671524294749; Tue, 20 Dec 2022 00:18:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1671524294; cv=none; d=google.com; s=arc-20160816; b=xAlm/ueG22sLSVhbvJPnHVxs/7zeTSY0EqfxA7AEJpGkYWZQ1KMxpaWgM0PbmHl9nl lXa8oBkAvrJsh8nRy0DrQKk9Hugx5vg2Wt1kNHdBbQW93cUgCtZdo8/usbw3L0qxEedU 8Czqn+7yBgYV7brpHf0sGhMbQieVk8zMKJRst27g7d6mm7K17N2LxuwSomO4Kzvz1L0H PWPSzrbZB3giuUGXVskQ8DtoD1UUYnu0RWeTQdTcufExpIwhkZez1wmUc+dzVmZNuuHm S5B0U3gtaDQGsNX55iHTWOF4LRbVthX3AxLI/GM6U2xp2/My5vpAkdzSP4DH5a6PknUL fU3g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=xMHCThwwrzWI9ikutEtTB2GTtOhVtJ91QPNRaSI4jOM=; b=zde8mpLUOhljZ00Lgk0ylHV3AaTAjI4RZ7qjAY9n1T5T7LSAa5fOROzoawV+0Qk1sR w2U1ajD64JcK1kBXwevIglAShS2fuwmzXbzMguaJcwGa+3Z9OcNDSKIHaW99v+fMqhC1 jVisbRM23kQJEpoG4IAlryTOE9F49kl9jLyBHPU7zqIlBwBUo1ioygNlVg7u8LHG6p4w LAHvBg+tXk12qXe9FeE1NIfiR2mthbof2tVat4LFTkzUr5+jMaj+m12qDDloU3DruDtr NZBIVMtaQv1nMendvDCnh6WpLKIvUW0+H8EzCMiKp1kRxa73uipbn8NvqiqW1i7CgMrl aBNg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id k11-20020a056a00168b00b005749a466300si14123563pfc.71.2022.12.20.00.18.04; Tue, 20 Dec 2022 00:18:14 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233364AbiLTHnz (ORCPT + 71 others); Tue, 20 Dec 2022 02:43:55 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57342 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229500AbiLTHnx (ORCPT ); Tue, 20 Dec 2022 02:43:53 -0500 Received: from cstnet.cn (smtp80.cstnet.cn [159.226.251.80]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id DFF5DF72 for ; Mon, 19 Dec 2022 23:43:51 -0800 (PST) Received: from localhost.localdomain (unknown [124.16.138.125]) by APP-01 (Coremail) with SMTP id qwCowACXwO6qZ6FjaKwRCA--.1506S2; Tue, 20 Dec 2022 15:43:38 +0800 (CST) From: Jiasheng Jiang To: almaz.alexandrovich@paragon-software.com, nathan@kernel.org, ndesaulniers@google.com, trix@redhat.com Cc: ntfs3@lists.linux.dev, linux-kernel@vger.kernel.org, llvm@lists.linux.dev, Jiasheng Jiang Subject: [PATCH] fs/ntfs3: Add missing check for kmemdup Date: Tue, 20 Dec 2022 15:43:36 +0800 Message-Id: <20221220074336.24258-1-jiasheng@iscas.ac.cn> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-CM-TRANSID: qwCowACXwO6qZ6FjaKwRCA--.1506S2 X-Coremail-Antispam: 1UD129KBjvdXoWruFWrJF1rCFyUtr1UWFWruFg_yoWxZrb_tF ZrC3WrXw17tr1vk3WDt3yrtws3uws3Jrn5WrZ7KF13JF98Ja1Y9rWktrs8Jw4xW34FgF48 G3s0kFy5ZrnI9jkaLaAFLSUrUUUUUb8apTn2vfkv8UJUUUU8Yxn0WfASr-VFAUDa7-sFnT 9fnUUIcSsGvfJTRUUUbcxFF20E14v26r4j6ryUM7CY07I20VC2zVCF04k26cxKx2IYs7xG 6rWj6s0DM7CIcVAFz4kK6r1j6r18M28lY4IEw2IIxxk0rwA2F7IY1VAKz4vEj48ve4kI8w A2z4x0Y4vE2Ix0cI8IcVAFwI0_Xr0_Ar1l84ACjcxK6xIIjxv20xvEc7CjxVAFwI0_Gr0_ Cr1l84ACjcxK6I8E87Iv67AKxVW8Jr0_Cr1UM28EF7xvwVC2z280aVCY1x0267AKxVWxJr 0_GcWle2I262IYc4CY6c8Ij28IcVAaY2xG8wAqx4xG64xvF2IEw4CE5I8CrVC2j2WlYx0E 2Ix0cI8IcVAFwI0_Jrv_JF1lYx0Ex4A2jsIE14v26r4j6F4UMcvjeVCFs4IE7xkEbVWUJV W8JwACjcxG0xvY0x0EwIxGrwACjI8F5VA0II8E6IAqYI8I648v4I1lc2xSY4AK67AK6r4x MxAIw28IcxkI7VAKI48JMxC20s026xCaFVCjc4AY6r1j6r4UMI8I3I0E5I8CrVAFwI0_Jr 0_Jr4lx2IqxVCjr7xvwVAFwI0_JrI_JrWlx4CE17CEb7AF67AKxVWUtVW8ZwCIc40Y0x0E wIxGrwCI42IY6xIIjxv20xvE14v26r1j6r1xMIIF0xvE2Ix0cI8IcVCY1x0267AKxVWUJV W8JwCI42IY6xAIw20EY4v20xvaj40_Jr0_JF4lIxAIcVC2z280aVAFwI0_Jr0_Gr1lIxAI cVC2z280aVCY1x0267AKxVW8JVW8JrUvcSsGvfC2KfnxnUUI43ZEXa7VUjE1v3UUUUU== X-Originating-IP: [124.16.138.125] X-CM-SenderInfo: pmld2xxhqjqxpvfd2hldfou0/ X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_PASS, SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add check for the return value of the kmemdup since it may return NULL pointer if allocation fails. Fixes: b46acd6a6a62 ("fs/ntfs3: Add NTFS journal") Signed-off-by: Jiasheng Jiang --- 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; -- 2.25.1