Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752726AbcLCO61 (ORCPT ); Sat, 3 Dec 2016 09:58:27 -0500 Received: from m50-132.163.com ([123.125.50.132]:54980 "EHLO m50-132.163.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751219AbcLCO6Z (ORCPT ); Sat, 3 Dec 2016 09:58:25 -0500 From: Pan Bian To: David Howells , Herbert Xu , "David S. Miller" , keyrings@vger.kernel.org, linux-crypto@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Pan Bian Subject: [PATCH 1/1] crypto: asymmetric_keys: set error code on failure Date: Sat, 3 Dec 2016 22:57:04 +0800 Message-Id: <1480777024-7410-1-git-send-email-bianpan201602@163.com> X-Mailer: git-send-email 1.9.1 X-CM-TRANSID: DNGowACXne1B3UJYB806IQ--.22589S3 X-Coremail-Antispam: 1Uf129KBjvdXoWrtr4UJr17Kw1DurWDKr4Uurg_yoWDurgEg3 95Xw4vvr1rJaykAr42kryFqr1Igr13GF95trW3KFyIya43Ga1kuFnIkrn5ZryUX3yYqFWD Gwsxtr13Jr9rXjkaLaAFLSUrUUUUUb8apTn2vfkv8UJUUUU8Yxn0WfASr-VFAUDa7-sFnT 9fnUUvcSsGvfC2KfnxnUUI43ZEXa7IUYtEfUUUUUU== X-Originating-IP: [222.131.246.88] X-CM-SenderInfo: held01tdqsiiqwqsqiywtou0bp/xtbBohs14FaDq2KIWAABsh Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1004 Lines: 33 From: Pan Bian In function public_key_verify_signature(), returns variable ret on error paths. When the call to kmalloc() fails, the value of ret is 0, and it is not set to an errno before returning. This patch fixes the bug. Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=188891 Signed-off-by: Pan Bian --- crypto/asymmetric_keys/public_key.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/crypto/asymmetric_keys/public_key.c b/crypto/asymmetric_keys/public_key.c index fd76b5f..1dc65ba 100644 --- a/crypto/asymmetric_keys/public_key.c +++ b/crypto/asymmetric_keys/public_key.c @@ -123,8 +123,10 @@ int public_key_verify_signature(const struct public_key *pkey, outlen = crypto_akcipher_maxsize(tfm); output = kmalloc(outlen, GFP_KERNEL); - if (!output) + if (!output) { + ret = -ENOMEM; goto error_free_req; + } sg_init_one(&sig_sg, sig->s, sig->s_size); sg_init_one(&digest_sg, output, outlen); -- 1.9.1