Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp4597311pxj; Wed, 12 May 2021 08:57:43 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzOdB1ALfsPH2RoGkvbCSomue4YKvxPBk19kvdDzdy3fxvYr2pdDqgMXXbXFb3bvfR0KbRr X-Received: by 2002:aca:1007:: with SMTP id 7mr7836135oiq.134.1620835063302; Wed, 12 May 2021 08:57:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620835063; cv=none; d=google.com; s=arc-20160816; b=zLP36CBTCoIxWd5R8DnfLp7hZxBkFqJwMUnmWHBlD5F8LUBV6zQtFWvabi3OX6PXMr YjAlBkWDSk+i4fCNpKi8s4Jy+SW7Qq7SipknnCRYwN2ogATiAmkkJjM8fB3Gamy6feee Z0zQzlTqikcHFLsK9xrxnGcQe2SMkDRpj3SQfShJIty1VX1Qm2f9FoU3DY4auSBp2976 n5TQPC6uOpiP4HmND8nekKc0Ft2o1E1Tzb73LPvRTcD0Meg2fCx3PpwsP+Pg464V4XmE GXET7L/NDNmrI4UVuSXeVvG1XsjWR+raGOzMsSsSrjn78MAU4SZuy0RN0Zusfw5Yt5Vj Oibw== 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=K8EEVMc3YSc3YnzPxntux6FKgZ6kUhIGN8Er7I+kPxk=; b=SJaymWT4oA87xyIwwZ1j4mze+Ru24rDJWMzVxWFqUkzugEZNOgJCULoLF89DrgeDYc aRBIwRu0taLZ0JC4Kh3ytvU7XG1tAKxlOX08RjRFdrC9LQWpPLPOndIpag34tI9gfShV PCZq46rqKyKRzGSoZDq37Bnj1bPVXSlFZBhc5IDxsBVMnzztXmxTdQhZ88lHK6oteDhw OVuqQUyNxWMivUMsFZaLQ/xi/9Rho0UHcdvXJyOMjQVXHDXpc2l57LXGNWQ/0CbislOI s/tHhIbiLejVT39y7kpebwIqTXQdX+uECMaMY6oZHACDUJ1xJqlhw7nDTFWw1Npe2hvy eLvg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=igmP6KRi; 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 i4si296788ooj.69.2021.05.12.08.57.29; Wed, 12 May 2021 08:57:43 -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=@linuxfoundation.org header.s=korg header.b=igmP6KRi; 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 S237632AbhELP4A (ORCPT + 99 others); Wed, 12 May 2021 11:56:00 -0400 Received: from mail.kernel.org ([198.145.29.99]:40990 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235137AbhELP0z (ORCPT ); Wed, 12 May 2021 11:26:55 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 6A1F061A06; Wed, 12 May 2021 15:11:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1620832307; bh=+ZSX+yPtuGULCRIss4T0JsrpfGrp9F8Pn8qWcb3paSc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=igmP6KRiLxo1ROiKckXZysaViywbjDZfFVvdw9qTJWLSsloWIWZlaQKfmdRovJdwV BqkM3JcOah35K359htNMyvbD1hBMhSnibcm7OgWeYfzgS4EOr/RXMyB1H7gfTr1b8v vEyRZEcDD5ec3ZUouHOcJLF/sg8cD0cOfPEkpVIQ= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Colin Ian King , Corentin Labbe , Herbert Xu , Sasha Levin Subject: [PATCH 5.10 227/530] crypto: sun8i-ss - Fix memory leak of pad Date: Wed, 12 May 2021 16:45:37 +0200 Message-Id: <20210512144827.290049604@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210512144819.664462530@linuxfoundation.org> References: <20210512144819.664462530@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: Colin Ian King [ Upstream commit 50274b01ac1689b1a3f6bc4b5b3dbf361a55dd3a ] It appears there are several failure return paths that don't seem to be free'ing pad. Fix these. Addresses-Coverity: ("Resource leak") Fixes: d9b45418a917 ("crypto: sun8i-ss - support hash algorithms") Signed-off-by: Colin Ian King Acked-by: Corentin Labbe Tested-by: Corentin Labbe Signed-off-by: Herbert Xu Signed-off-by: Sasha Levin --- drivers/crypto/allwinner/sun8i-ss/sun8i-ss-hash.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/crypto/allwinner/sun8i-ss/sun8i-ss-hash.c b/drivers/crypto/allwinner/sun8i-ss/sun8i-ss-hash.c index 541bcd814384..756d5a783548 100644 --- a/drivers/crypto/allwinner/sun8i-ss/sun8i-ss-hash.c +++ b/drivers/crypto/allwinner/sun8i-ss/sun8i-ss-hash.c @@ -347,8 +347,10 @@ int sun8i_ss_hash_run(struct crypto_engine *engine, void *breq) bf = (__le32 *)pad; result = kzalloc(digestsize, GFP_KERNEL | GFP_DMA); - if (!result) + if (!result) { + kfree(pad); return -ENOMEM; + } for (i = 0; i < MAX_SG; i++) { rctx->t_dst[i].addr = 0; @@ -434,10 +436,9 @@ int sun8i_ss_hash_run(struct crypto_engine *engine, void *breq) dma_unmap_sg(ss->dev, areq->src, nr_sgs, DMA_TO_DEVICE); dma_unmap_single(ss->dev, addr_res, digestsize, DMA_FROM_DEVICE); - kfree(pad); - memcpy(areq->result, result, algt->alg.hash.halg.digestsize); theend: + kfree(pad); kfree(result); crypto_finalize_hash_request(engine, breq, err); return 0; -- 2.30.2