Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp3617177pxb; Mon, 24 Jan 2022 13:36:54 -0800 (PST) X-Google-Smtp-Source: ABdhPJzSHh6JJRLysTLAzPQYjrQH3TD5Ok/kAu/xSY2LPH/0q8rtPZFDb0ZzTTtSO7P/qHuQZNNs X-Received: by 2002:a17:902:a601:b0:148:adf2:9725 with SMTP id u1-20020a170902a60100b00148adf29725mr16096508plq.136.1643060214437; Mon, 24 Jan 2022 13:36:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643060214; cv=none; d=google.com; s=arc-20160816; b=y5INymrZ4/5JfBWXGv46+c1aG0Sj4GGHd7MMpG+bCkv/aejmK/S5cJ8/VaspFSKy6W FT5OkhY9E0LdoJpaASdKkB6sUrn3dVPEPOfeTmdtFutjbbI6QsdDCBzU/fYqYFyL05g5 F/eGLzhsrTlrrOTvYNl/rlW0NpZGGlIZwwOW4FdyCRxDgBL2i1Sa5GGMTGT/mzZLJxqB jiki5RbpwhmqsQBxZnovGypFczQwIZQbBzWsWxDbUZA94J+Z5QR+ptI66yowyUYM8BMx ZB4PDb+SAesZ2CYA6XiI7i/ad2qDT25bo8qoZGk7kR+/88gQE+b4sect6QtlJHssslfC DPEA== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=f2N6bw2WWAcgb4XTzRp4Vw/cUPV7QxO0FyMkRjDMmSk=; b=KaPAPqeto0Tv0hHv11o16veFxX/YWm/NJRdfOSX5c8DtqWtAhKcphsunjG9d83/TqJ MJsKpMNcxtl9RPmAAw+OcmIEj++dHDHxQXXXqPPkt2NplRQYKd1wZYpPXA6dhRt6jP1n 1CgvXmidDlQcSKMiJKf9pcCjVkucwAb7fHKmdIG/+5OgdJGs11E1puNPdrEPK85LNw/A 3zrFdK8v3JeAdQ/idiWtgKOEplRSYDnmBBPv7CLcsf7fl6C3koT5lTu93a5CJFM6SREp +1n3UzkzDuCNs3nZ6GFg/LydU6tO+6HTHuXBDIqGiMKqMrgt+ieUguZSnDf5Y1kIE4R1 79rg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=jfVCsIhF; 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=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id z6si3169294pfe.233.2022.01.24.13.36.41; Mon, 24 Jan 2022 13:36:54 -0800 (PST) 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=@linuxfoundation.org header.s=korg header.b=jfVCsIhF; 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=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345677AbiAXVMm (ORCPT + 99 others); Mon, 24 Jan 2022 16:12:42 -0500 Received: from dfw.source.kernel.org ([139.178.84.217]:33246 "EHLO dfw.source.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1355652AbiAXUh4 (ORCPT ); Mon, 24 Jan 2022 15:37:56 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 4E9876152F; Mon, 24 Jan 2022 20:37:56 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5F6CDC340E8; Mon, 24 Jan 2022 20:37:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1643056675; bh=Dw55RYZD/DX3A6O8uk0ifo8PqWSjLQRn9YgpgdbiIv4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jfVCsIhFnxQzSfA8dcgeOtxyFoQsbpl+4b5vbkZAu8Ew9kXtTmj0A+5jjk0em2Tfg XbKFj01X1LZ6L7E9eZio3l8Lg7Y/2nG9CfiY6kOq6ZHLsToyaTCXmXQGz2z7bkbZD2 luRVALvylEL9v1k6U+aiiZRXhREpbv8u0Qji6njw= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Weili Qian , Herbert Xu , Sasha Levin Subject: [PATCH 5.15 563/846] crypto: hisilicon/hpre - fix memory leak in hpre_curve25519_src_init() Date: Mon, 24 Jan 2022 19:41:20 +0100 Message-Id: <20220124184120.454213089@linuxfoundation.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220124184100.867127425@linuxfoundation.org> References: <20220124184100.867127425@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Weili Qian [ Upstream commit 51fa916b81e5f406a74f14a31a3a228c3cc060ad ] hpre_curve25519_src_init() allocates memory for 'ptr' before calling memcmp(). If memcmp() returns 0, the function will return '-EINVAL' without freeing memory. Signed-off-by: Weili Qian Signed-off-by: Herbert Xu Signed-off-by: Sasha Levin --- drivers/crypto/hisilicon/hpre/hpre_crypto.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/crypto/hisilicon/hpre/hpre_crypto.c b/drivers/crypto/hisilicon/hpre/hpre_crypto.c index a032c192ef1d6..7ba7641723a0b 100644 --- a/drivers/crypto/hisilicon/hpre/hpre_crypto.c +++ b/drivers/crypto/hisilicon/hpre/hpre_crypto.c @@ -1865,7 +1865,7 @@ static int hpre_curve25519_src_init(struct hpre_asym_request *hpre_req, */ if (memcmp(ptr, p, ctx->key_sz) == 0) { dev_err(dev, "gx is p!\n"); - return -EINVAL; + goto err; } else if (memcmp(ptr, p, ctx->key_sz) > 0) { hpre_curve25519_src_modulo_p(ptr); } -- 2.34.1