Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp3358655pxk; Mon, 5 Oct 2020 07:48:45 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwLrlH7FcwTZaVgSl62S8aQuVdMrkBpsdT2F88q+0Rgu3RjqPndD8KkjEAsIAUoA83F7ldC X-Received: by 2002:a05:6402:84f:: with SMTP id b15mr17709749edz.149.1601909324971; Mon, 05 Oct 2020 07:48:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1601909324; cv=none; d=google.com; s=arc-20160816; b=pWOYI5sQasqnudnbTwWyBYEY0kk3FuhvQF3Ql0YYx1OHATknm/+YeCZImZjKNtMh67 OW6c8/Vf0MNQIzM54V/hb0yVXNoc4QtrWbGl4KCOLjipZG9V6GSgQzjGj1uWAnfwqKRm +my6EcuLTOzL+NVAL4fHgs0R6Zm3X/ko954thuNyPx0v3kLXpCju/sHE7d2J/3OM1zsw aRnw+T4Ew4XMePF+5K2CJJr7AfPgvbs/KBwa9J3Zg5JgB15GLlMvuLnK9nU63/6OVNhe Wqr7PNZNu7kASR00kJZEiCUO1+GEHJ1lAiPO7KNX3SErNE8RMD9QJbJjuYIxVV+ZrU6b tHSQ== 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=SzJb+y7n00HsRW1iyOLntTyUXnu70h7SvGya6Ch990Y=; b=II/x6s39/0lEdBSeMmhy5DNn1rZuPtjG8+w4YlGViBUzaBXPF3G2e5k/Pkr8+W7YKT E/fTG6jnjpMjZCjYeL8hHnAYOqGazvlbMXqIRmYhPWRUW3cG+W8YsdvifY7TNb5DQnB/ 5KLjI0hgEoFgAxGQux4q22JT4QdoGdvLNjKi8IWF1cDbmWekcSQfLgnrLw1JSGyqM3yK Ejdvt0edWx1nJ+oKtO2XktDUjo0StJax7XGv19E6G2/yVHnBp6E+EcJhejKpnr6oEDv9 u9We8jOs7C4o4IcdlgUdSkcARRmQG8WFNkDS7HfYON4GF4HHstMcx04W0xPq02N37ZBs SvWw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id d22si110718edq.553.2020.10.05.07.48.12; Mon, 05 Oct 2020 07:48:44 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726570AbgJEOrJ (ORCPT + 99 others); Mon, 5 Oct 2020 10:47:09 -0400 Received: from out30-43.freemail.mail.aliyun.com ([115.124.30.43]:58057 "EHLO out30-43.freemail.mail.aliyun.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726860AbgJEOqf (ORCPT ); Mon, 5 Oct 2020 10:46:35 -0400 X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R181e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=e01e04420;MF=tianjia.zhang@linux.alibaba.com;NM=1;PH=DS;RN=8;SR=0;TI=SMTPD_---0UB3G6jf_1601909189; Received: from localhost(mailfrom:tianjia.zhang@linux.alibaba.com fp:SMTPD_---0UB3G6jf_1601909189) by smtp.aliyun-inc.com(127.0.0.1); Mon, 05 Oct 2020 22:46:29 +0800 From: Tianjia Zhang To: Herbert Xu , David Howells , "David S. Miller" , Gilad Ben-Yossef , linux-crypto@vger.kernel.org, keyrings@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Tianjia Zhang Subject: [PATCH] X.509: fix error return value on the failed path Date: Mon, 5 Oct 2020 22:46:28 +0800 Message-Id: <20201005144628.83875-1-tianjia.zhang@linux.alibaba.com> X-Mailer: git-send-email 2.24.3 (Apple Git-128) MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org When memory allocation fails, an appropriate return value should be set. Fixes: 215525639631 ("X.509: support OSCCA SM2-with-SM3 certificate verification") Signed-off-by: Tianjia Zhang --- crypto/asymmetric_keys/public_key_sm2.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/crypto/asymmetric_keys/public_key_sm2.c b/crypto/asymmetric_keys/public_key_sm2.c index 7325cf21dbb4..66b614e1eccd 100644 --- a/crypto/asymmetric_keys/public_key_sm2.c +++ b/crypto/asymmetric_keys/public_key_sm2.c @@ -36,8 +36,10 @@ int cert_sig_digest_update(const struct public_key_signature *sig, desc_size = crypto_shash_descsize(tfm) + sizeof(*desc); desc = kzalloc(desc_size, GFP_KERNEL); - if (!desc) + if (!desc) { + ret = -ENOMEM; goto error_free_tfm; + } desc->tfm = tfm; -- 2.24.3 (Apple Git-128)