Received: by 2002:a25:e74b:0:0:0:0:0 with SMTP id e72csp785052ybh; Wed, 15 Jul 2020 15:29:21 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz0lobI8mDIELQEwsroiEazuwCy1iOaFXVjdujhrQQzOMtPAO/XxXplRddNcIWsJXHUKeZa X-Received: by 2002:a17:906:ecb6:: with SMTP id qh22mr1003249ejb.230.1594852161569; Wed, 15 Jul 2020 15:29:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1594852161; cv=none; d=google.com; s=arc-20160816; b=NkHOIOo/FvxvQGpSCQrb1DsWCYwZ3JH9CbXG0rRiypIiOfuffeZHEXKkZFxqp5zU9A 1oiP0cQK1QUKAijVC8CED+RUbkLt/2z3jDly9ia8WNxAPkLeUGZQmcosSNm2x76QTYoP u59rNqq6JqR2Wt3U+If7y4WRH3w4H42hC+x8ce9nFkMCFjOiX3PEz20rj0f2np/0W/P+ Gx6IIfbl39x3fZYsb/e/nf5KfDk+RTQTsLRpL8G52o9vCVFUCQvR3nWBcKR7Z39IDsmk AfP/CaT/6FqftNq+WGsmItiGVt0i1le/XtB+gGE6TZR28KmbhbVd2JAR71onGgbPODwW kdQA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:message-id:date:cc:to:from:subject:organization :dkim-signature; bh=r7ysqoJ771cWpq2r7U8vAXss+T0bwN4WnRyfVotsoz8=; b=bIivlvF8KvVtxfVfxmXKRYvQW4geaIDmhAlKLBfGkVQl84MNNzY3i+nLE6D3rHvW/d LkVmM+zuPjrok+asl40yUl2TU1JoBNwmTnnB+6ern/8FAJ5HepHE+y2D3RU4nhQU2W9l rvEr+6nug480xillGZXVRKBaQoMrfoJGCHvAg7VUlImp9thBKCu5j1pKPV98dPExCZch 2abLKKtJfecP9i2IVU/0zjSEEpTnx3HT02W5lE0t+FuKXDERFJBcIH3YKmFBy61Z2ll1 /AfnyOLMy5O1OfMsSgZY65WL2wqmbNoMlhnpinGWFATJwxgXr98C8X0X77PE42uA5ckv EhNA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=hxbzXSZ7; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id d19si2094835edv.53.2020.07.15.15.28.58; Wed, 15 Jul 2020 15:29:21 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=hxbzXSZ7; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726986AbgGOW2s (ORCPT + 99 others); Wed, 15 Jul 2020 18:28:48 -0400 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:27209 "EHLO us-smtp-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726776AbgGOW2r (ORCPT ); Wed, 15 Jul 2020 18:28:47 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1594852126; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=r7ysqoJ771cWpq2r7U8vAXss+T0bwN4WnRyfVotsoz8=; b=hxbzXSZ7LXiPE5d5p+CleAXl/rDJp3mLjsUEF3srx6pC1JnSWzVM7saus+aPA6/AQsvw3j f+orP28koUFqKafotD1//5C/KBMuAgtH14ua1WJPBwA9fTeAKgVFjQges4kieFZwbP05Yw ezzet+l4ulEniTS01Ln2kchFpHxtI5o= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-31-A0bR1z3CN4aAii1dDZUDNw-1; Wed, 15 Jul 2020 18:28:42 -0400 X-MC-Unique: A0bR1z3CN4aAii1dDZUDNw-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id A10231083; Wed, 15 Jul 2020 22:28:40 +0000 (UTC) Received: from warthog.procyon.org.uk (ovpn-112-113.rdu2.redhat.com [10.10.112.113]) by smtp.corp.redhat.com (Postfix) with ESMTP id 64D4110013C2; Wed, 15 Jul 2020 22:28:39 +0000 (UTC) Organization: Red Hat UK Ltd. Registered Address: Red Hat UK Ltd, Amberley Place, 107-111 Peascod Street, Windsor, Berkshire, SI4 1TE, United Kingdom. Registered in England and Wales under Company Registration No. 3798903 Subject: [PATCH] keys: asymmetric: fix error return code in software_key_query() From: David Howells To: torvalds@linux-foundation.org Cc: Wei Yongjun , dhowells@redhat.com, jarkko.sakkinen@linux.intel.com, keyrings@vger.kernel.org, linux-security-module@vger.kernel.org, linux-kernel@vger.kernel.org Date: Wed, 15 Jul 2020 23:28:38 +0100 Message-ID: <159485211858.2340757.9890754969922775496.stgit@warthog.procyon.org.uk> User-Agent: StGit/0.22 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Wei Yongjun Fix to return negative error code -ENOMEM from kmalloc() error handling case instead of 0, as done elsewhere in this function. Fixes: f1774cb8956a ("X.509: parse public key parameters from x509 for akcipher") Signed-off-by: Wei Yongjun Signed-off-by: David Howells --- crypto/asymmetric_keys/public_key.c | 1 + 1 file changed, 1 insertion(+) diff --git a/crypto/asymmetric_keys/public_key.c b/crypto/asymmetric_keys/public_key.c index d7f43d4ea925..e5fae4e838c0 100644 --- a/crypto/asymmetric_keys/public_key.c +++ b/crypto/asymmetric_keys/public_key.c @@ -119,6 +119,7 @@ static int software_key_query(const struct kernel_pkey_params *params, if (IS_ERR(tfm)) return PTR_ERR(tfm); + ret = -ENOMEM; key = kmalloc(pkey->keylen + sizeof(u32) * 2 + pkey->paramlen, GFP_KERNEL); if (!key)