From patchwork Wed Jun 22 02:02:08 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Li Qiong X-Patchwork-Id: 583967 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8D6CDC43334 for ; Wed, 22 Jun 2022 02:03:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1356079AbiFVCDZ (ORCPT ); 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 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;