From patchwork Mon Oct 24 08:30:07 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Li kunyu X-Patchwork-Id: 8249 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp333166wru; Mon, 24 Oct 2022 02:01:21 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6RZIg+fPgDb54E8IniYj+KAuvbcMW4h3HbQpVRSrzFpMw4j+yYH4plTFJEULzH04gA5DaR X-Received: by 2002:a17:907:d10:b0:79a:a1fe:8be5 with SMTP id gn16-20020a1709070d1000b0079aa1fe8be5mr13523883ejc.125.1666602081534; Mon, 24 Oct 2022 02:01:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666602081; cv=none; d=google.com; s=arc-20160816; b=z+lxoy2GRNXQECNcVJXabuzU7ItZ2tliX3Ho20SqzliYFKTZXpeV+ur9VDPGdfu4Vf Ti1Bi+W7Z32+rgbQmi8PB6FmsIXPQs4HbE2URHyVCp/hVNE6MsJth2nkElnp4CF5trRL EtkJ41MR6A9h5ULmEVCgnocPVYci/Ru1bmCtcwp9smqkdIjpDgXaRqGEcsEQ93ZTEnSH jMsuTJ1ewGuTfwLqhZaVs47uG7l6l2zluJyR7YpswQog0PbiKLdrDtSFQF41sRnQ1ocB TrH0xSOn++/BiH9vFAHkQGCvvswBd1BQ6gSVkdWOLvsOCQ+vWKLUgpQUah9YLq12p64c d0Rg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:message-id:date:subject:cc:to:from; bh=GsjGDaXmt/AC7DLHnYD9EjdCR8OdgY2YG3nKLXkpPeQ=; b=VL59lBrQjzVlMu4Vy9Aiz4YkiIlfhAC19Nrqyh7KV6WEc5DIhgohiwZZUKFx77HCc8 cPCcR6uH5BbJc4lMZywFH4ouvyYNMsBYDG4h3HhiV4icwfPJ/6OV1LZSZbwomMW9oNOT D2IJDnSIWGG5mvX1RQEiWn79tJDvRT0CCJ4iFhocyqQL9Mon//bqnkurppCq0Wc0G1WM ZfAw8WggIr1yvrIM7hrcgvLdTyRz2LRjNqdyTinERYRcjOIT4jL669vy/k59otqj3dgL YT9m0qMFFdWX3UckqmmVthL+HDCztV0BSJc0bqQqey1ohXmQL4w0gqtd6T8Eocg8q/uU GITw== 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 Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id cr16-20020a170906d55000b0078372cf516csi18593290ejc.229.2022.10.24.02.00.57; Mon, 24 Oct 2022 02:01:21 -0700 (PDT) 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 S230000AbiJXIey (ORCPT + 99 others); Mon, 24 Oct 2022 04:34:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52170 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230336AbiJXIeq (ORCPT ); Mon, 24 Oct 2022 04:34:46 -0400 Received: from mail.nfschina.com (mail.nfschina.com [124.16.136.209]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 5C6C82AE1B; Mon, 24 Oct 2022 01:34:44 -0700 (PDT) Received: from localhost (unknown [127.0.0.1]) by mail.nfschina.com (Postfix) with ESMTP id 45CC81E80D74; Mon, 24 Oct 2022 16:28:59 +0800 (CST) X-Virus-Scanned: amavisd-new at test.com Received: from mail.nfschina.com ([127.0.0.1]) by localhost (mail.nfschina.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id gWT6Xz_bwSwN; Mon, 24 Oct 2022 16:28:56 +0800 (CST) Received: from localhost.localdomain (unknown [219.141.250.2]) (Authenticated sender: kunyu@nfschina.com) by mail.nfschina.com (Postfix) with ESMTPA id 958F71E80CA5; Mon, 24 Oct 2022 16:28:56 +0800 (CST) From: Li kunyu To: krisman@collabora.com Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, Li kunyu Subject: [PATCH] unicode: mkutf8data: Add malloc allocation check Date: Mon, 24 Oct 2022 16:30:07 +0800 Message-Id: <20221024083007.179093-1-kunyu@nfschina.com> X-Mailer: git-send-email 2.18.2 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_NONE 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747558943981301738?= X-GMAIL-MSGID: =?utf-8?q?1747558943981301738?= If malloc allocation fails, NULL is returned. Signed-off-by: Li kunyu --- fs/unicode/mkutf8data.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/fs/unicode/mkutf8data.c b/fs/unicode/mkutf8data.c index e06404a6b106..a929ddf1438c 100644 --- a/fs/unicode/mkutf8data.c +++ b/fs/unicode/mkutf8data.c @@ -495,6 +495,9 @@ static struct node *alloc_node(struct node *parent) int bitnum; node = malloc(sizeof(*node)); + if (!node) + return NULL; + node->left = node->right = NULL; node->parent = parent; node->leftnode = NODE;