From patchwork Mon Oct 24 04:51:50 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Li kunyu X-Patchwork-Id: 8159 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp254115wru; Sun, 23 Oct 2022 21:54:09 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6sFV+7gC1PQ7uTnTcn3GoNvzmZUYxMn41MuKxsBym9T+o7t0O51t//K/WN3FNI+RqfDYbz X-Received: by 2002:a17:90b:38c4:b0:20d:9dfa:4339 with SMTP id nn4-20020a17090b38c400b0020d9dfa4339mr68934480pjb.74.1666587249203; Sun, 23 Oct 2022 21:54:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666587249; cv=none; d=google.com; s=arc-20160816; b=ydB6VyZSdZEMv6Ac4SwMzwufYNPa2xR9xQmHwIRr6qdUveakMwHDf0ZB5HFKXDv1AD sYR1yD518T7+YA/zrPPEc3sFU5RfrPVQjnrZ8yCcHwaR8RJS2+mqs5LiGd2yIHoUhWKx WouuE1FOfAYSKowfB0OBDrLZ0q4vsMo6BMbn9voql1wpGHwVZoVuPBYxbAu2NkEwNxda rawtCdXvIkdOB8VViTh5M7x2cAATYJjfIjSFs3WhRGriV01y+g/Hj2ffyH4VAbqL1V21 F6gK4bUsCj2MV8Cw7KRGAOHz9grJVKIzE9Ui7DG4qjFzeLqFSV8hlUFprp6GVa/CCJn1 g1xQ== 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=43hbfNd7QS0Rs/MdeSHlZ3XDSydAbtGZP6mkVk3wwGg=; b=hnNknfhu1uY+o6IuqolDm4CGB8KTPib2TWIeQdFDovJqgNWTMQWFBS0BDC1zCL8hqa T076QY2HWOqYdNEkb7ntQzojWduRJ4l7jkrc5VEVxmxkxMyKk8K4kppZjb10kbXnmp8b PZpJPYJs1nAR2osXDn3sioU0D+aDYVXW5AVfgYirHES0sJAd4HiUyIB0I+FXegMv7A43 hKI8UaKp8Rlp8oAwV9G14CyEqBS/9FY79LHj+yioAfFFLP67YyUvzOMF3LkoCCEqRqwF Q8frvURQ7sEi7X7Tvhwf0b3KRC7XenF38dw5JUHDwcuV/8+mo8VLOSApia4Qzt+nE+xP q1Lg== 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 mt5-20020a17090b230500b00213032c1b7esi3330184pjb.13.2022.10.23.21.53.56; Sun, 23 Oct 2022 21:54:09 -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 S229988AbiJXEv5 (ORCPT + 99 others); Mon, 24 Oct 2022 00:51:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56956 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229928AbiJXEvz (ORCPT ); Mon, 24 Oct 2022 00:51:55 -0400 Received: from mail.nfschina.com (unknown [124.16.136.209]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id CBD7C79924; Sun, 23 Oct 2022 21:51:54 -0700 (PDT) Received: from localhost (unknown [127.0.0.1]) by mail.nfschina.com (Postfix) with ESMTP id B5CB01E80D76; Mon, 24 Oct 2022 12:50:38 +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 JBDSWh3XdTol; Mon, 24 Oct 2022 12:50:36 +0800 (CST) Received: from localhost.localdomain (unknown [219.141.250.2]) (Authenticated sender: kunyu@nfschina.com) by mail.nfschina.com (Postfix) with ESMTPA id 1DF461E80D74; Mon, 24 Oct 2022 12:50:36 +0800 (CST) From: Li kunyu To: krisman@collabora.com Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, Li kunyu Subject: [PATCH 2/2] unicode: mkutf8data: Add malloc allocation check Date: Mon, 24 Oct 2022 12:51:50 +0800 Message-Id: <20221024045150.177521-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?1747543391543216239?= X-GMAIL-MSGID: =?utf-8?q?1747543391543216239?= Increase the judgment of malloc allocation, and return NULL if the condition is met. 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;