Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp4382707iog; Tue, 21 Jun 2022 19:11:23 -0700 (PDT) X-Google-Smtp-Source: AGRyM1syHBgJ/G0bVSllwshlOq6HW6bgYkSyht06l+PoG+bmkEf+/wzqlV7nJXvYLUxrHEi4iJNs X-Received: by 2002:a17:906:7c0c:b0:6f9:1fc:ebf3 with SMTP id t12-20020a1709067c0c00b006f901fcebf3mr924321ejo.403.1655863883253; Tue, 21 Jun 2022 19:11:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1655863883; cv=none; d=google.com; s=arc-20160816; b=Z9a0X5+hosdWsnk7RT0U1kgR/+zGQgyzZvEa1LG9Oz777fPI2ZP+XymbuqJ4mtHKIU tjRcP4mkCI3ix7AnWLFBqbktDGDpKdbMl7bH593aIAI71S8MZdQyX62u1x7Ng5sAOE4l e0WlATiTh7i1c/MSMGc8bW/oxSqlR7zVQ4VsGd75N5VyllThNPCNYqGRx1oM/d2iArxx lH/MVoqDVkgyhUnm1TZmjU3pMLwI3PCqJ9Q79UfbHSzHXbtZxWeTeGPe8NaPur98ozSv PH9n7i4+dLJ1PcbVCXUyQ1HC1dWNR8fmkuo5TIiBP/ueK65Dw+etnAKDv4+GQ+rZUSfy D9PQ== 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=hqdIwI4a304KS5JgQyggbr94mF616e4UcJfp5qzK0KU=; b=KXGY0p3X6OcnNUMBVx93bpvxIAZfy76EkkCixeAD6O6Q9SSuUAhI5tMkOv/f5l7vBu /Y5zK13qV7HXCOjYu4L7I+/r0CjWWqd/KcFZ31qnU1AFCJw6/EbkTJBmtoTYogM9G9I1 d8XJ3tBz1WLQmKm+6OSX6gUZqBbmbQxfk5eEdbVa6FLfDD+F6QY0fRmorUGBJeC7534g ORFbdoiJWykiuccdCtixT4kew5kxxUzX4KmXJPhP60FKE48n6QiezcYGkDl5CcRpeSN9 D8cRHvOINS9OrHB+k0X5GMQIw6itCwlu1sd7u184ZPhZ0NFcpV3MUh9BAp83N/9S0NLJ UKQg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-crypto-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 qk13-20020a1709077f8d00b00711d50b288fsi16148023ejc.547.2022.06.21.19.10.44; Tue, 21 Jun 2022 19:11:23 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-crypto-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-crypto-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1356079AbiFVCDZ (ORCPT + 99 others); Tue, 21 Jun 2022 22:03:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33858 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1356009AbiFVCDY (ORCPT ); Tue, 21 Jun 2022 22:03:24 -0400 Received: from mail.nfschina.com (unknown [IPv6:2400:dd01:100f:2:72e2:84ff:fe10:5f45]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 2C21B30543; Tue, 21 Jun 2022 19:03:23 -0700 (PDT) Received: from localhost (unknown [127.0.0.1]) by mail.nfschina.com (Postfix) with ESMTP id 9C70D1E80CD1; Wed, 22 Jun 2022 10:03:15 +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 B_IKXUawNFvw; Wed, 22 Jun 2022 10:03:13 +0800 (CST) Received: from localhost.localdomain (unknown [180.167.10.98]) (Authenticated sender: liqiong@nfschina.com) by mail.nfschina.com (Postfix) with ESMTPA id 5DBFA1E80C7D; Wed, 22 Jun 2022 10:03:12 +0800 (CST) From: Li Qiong To: Herbert Xu , "David S . Miller" , Maxime Coquelin , Alexandre Torgue , "Rafael J . Wysocki" Cc: linux-crypto@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, yuzhe@nfschina.com, renyu@nfschina.com, Li Qiong Subject: [PATCH] crypto: stm32 - Handle failure of kmalloc_array() Date: Wed, 22 Jun 2022 10:02:08 +0800 Message-Id: <20220622020208.25776-1-liqiong@nfschina.com> X-Mailer: git-send-email 2.11.0 X-Spam-Status: No, score=-1.1 required=5.0 tests=BAYES_00,RDNS_NONE, SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=no 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-crypto@vger.kernel.org As the possible failure of the kmalloc_array(), therefore it should be better to check it and return '-ENOMEM' on error. Signed-off-by: Li Qiong --- drivers/crypto/stm32/stm32-hash.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/crypto/stm32/stm32-hash.c b/drivers/crypto/stm32/stm32-hash.c index d33006d43f76..fc03e32e364f 100644 --- a/drivers/crypto/stm32/stm32-hash.c +++ b/drivers/crypto/stm32/stm32-hash.c @@ -970,6 +970,8 @@ static int stm32_hash_export(struct ahash_request *req, void *out) rctx->hw_context = kmalloc_array(3 + HASH_CSR_REGISTER_NUMBER, sizeof(u32), GFP_KERNEL); + if (!rctx->hw_context) + return -ENOMEM; preg = rctx->hw_context; -- 2.11.0