Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp768615pxf; Thu, 1 Apr 2021 13:04:21 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyIJ7g6aGHLSuYiHtIoZYgdWF+t499AcnJcpiWAi+IL3Zja3ozCyOsUxaeK4s1FHIg45xtx X-Received: by 2002:a05:6e02:e91:: with SMTP id t17mr8184491ilj.258.1617307461285; Thu, 01 Apr 2021 13:04:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1617307461; cv=none; d=google.com; s=arc-20160816; b=s5Tzz5DgZ/PAFLuNZkyc/wlMy9XLhGWANG3QzJlCYUus+H/SuZWCeRhXKvUJGBCTPH 3vuFZ8nuplXnhoYrPxuivCMeBylw7FFEXrinyX5QNORVnL5dIHp3Kdq0KxvyfgCj93mo QpmRrhTjjQ53oB9j0cR+UfNO9PDkxccsuRdKB+e1aVT+5oOyBsTLVoPgmn8EOSr+N6bC h1F7K7dLCansNXX3XNfliB60WKH69fvu7mHYPzXmoWxMBc3dKgkmfyLckh4Dwj4BTSCw IoEuoqQjjBdu+2E71LJKc9rQrZQYV7/lQ4K0718gW6V2DWVmTRXgfDYxLLRucguiA4Md zsIg== 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=Ci608fxbx6CN7Fk6fZK0jFBhtx15yjZDCdwmFEaPRv8=; b=kWPUei79zjtvDLJiX5ZyY4WQTI4i+gihT3X8IWLB3AttsQKxoaYg0RYQvdepReuZOd lbkcC15LCj1lUryJ3mYd7+QlP9cALIHVWE3ydf7TqnJm9zX2I1tRW1+/oC0gomW9vbed 5AhalmyRPlX3iRCwIWTsske0Rp66cjAu9CkziOgoItr33qrkW3eud9iKHUdtgDhjNHEA AeAxbWvSU28iMj5Dnx0kAnobpkcac0Y9j7+P5lnkLxFcWq6TLjtqrcb/D0bzM5sR5atA AsxbF3pH84suQ+Rpik52NbZXtr2NLIgsqBaHBiv9v7XGuhOvy0cqN3aCGUD45KzDyQd1 an3A== 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=canonical.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id q62si6147587jaa.15.2021.04.01.13.04.07; Thu, 01 Apr 2021 13:04:21 -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=canonical.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235623AbhDAUD3 (ORCPT + 99 others); Thu, 1 Apr 2021 16:03:29 -0400 Received: from youngberry.canonical.com ([91.189.89.112]:45358 "EHLO youngberry.canonical.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235440AbhDAUD0 (ORCPT ); Thu, 1 Apr 2021 16:03:26 -0400 Received: from 1.general.cking.uk.vpn ([10.172.193.212] helo=localhost) by youngberry.canonical.com with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1lRz5X-0007xh-9O; Thu, 01 Apr 2021 15:18:27 +0000 From: Colin King To: Corentin Labbe , Herbert Xu , "David S . Miller" , Maxime Ripard , Chen-Yu Tsai , Jernej Skrabec , linux-crypto@vger.kernel.org, linux-arm-kernel@lists.infradead.org Cc: kernel-janitors@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH][next] crypto: sun8i-ss: Fix memory leak of pad Date: Thu, 1 Apr 2021 16:18:27 +0100 Message-Id: <20210401151827.2015960-1-colin.king@canonical.com> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org From: Colin Ian King 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 --- 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 7d1fc9aba665..3c073eb3db03 100644 --- a/drivers/crypto/allwinner/sun8i-ss/sun8i-ss-hash.c +++ b/drivers/crypto/allwinner/sun8i-ss/sun8i-ss-hash.c @@ -348,8 +348,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; @@ -436,10 +438,9 @@ int sun8i_ss_hash_run(struct crypto_engine *engine, void *breq) 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