Received: by 2002:a05:6a10:9e8c:0:0:0:0 with SMTP id y12csp508907pxx; Wed, 28 Oct 2020 09:56:25 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwbpCu9vo9PWEtpBEwQGexYP/WY8oll5X/psQ6LddbP9YCZjH8OjNnxSdAzoagdL/qzKlHP X-Received: by 2002:aa7:c256:: with SMTP id y22mr8773526edo.108.1603904185313; Wed, 28 Oct 2020 09:56:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603904185; cv=none; d=google.com; s=arc-20160816; b=AenZjjxNf9o56DshPe+4dYmYrJYFiN4JZA1MHnMSap8FgjSoeM9fkAfl3NEkq1x2Yq ojlFUNlvHSNR0H4MdZNjIgockO5hFEan+aIzhurY2BlhqC7dkJDE1WqtPXYAZmnGbkLE koFFK1h8tGCSFqWcQukyzz+8HPia2efLoN0I0aZdkgTT8v7DWupPyM6VRNqmr94TooOJ rgaRD08GE8b+y+g++E8TqtwYubguzreDo2I99F10c07xeJvh/5VA0SXOo7xFfGjeOWmB UxpTXtJCMze/HLepNA7LG9EYvu/pjd8+86g/rR6v3nYl/2X3eGOzOqquS/r6+Ka/ptCw vfuQ== 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=3ZxSafw2D0iQdmJusJeq/8LooRHQ4UEwJ3sZaU/JKTg=; b=LPggPKEyNWdhkxBkGBAqmqE7y+sHTInm8OS906+s38TC88whZkpDLV3yNYSkT5/G5P VXtJpxK9+uijGg5pNHV32l/0tlyK6rWixZIzZTUBqRm/TpUo3M+152oXfUUUzO7k+YiP PXsSrgketbzKLRbkED+QwnFYFlSP9XG0MNsRk4k31UldnuC8zyLYftNX+r6R0r87Ep45 bkqzFdgFB7pvP6xg5i0bzlU2gCUEaam4ZrQWu+fNFfHPxUXdlizw2NNWVfWsEvgTFqth ZrzfnIVZkEymWPmdRlqcOJH1jJiFY0NsxdENe6z+ITMOqi5gBsRgb1zMSjq2+WrUUzkc y+Zw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=qG74gNjZ; 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=fail (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 c8si22307edl.252.2020.10.28.09.56.03; Wed, 28 Oct 2020 09:56:25 -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=@kernel.org header.s=default header.b=qG74gNjZ; 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=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1818915AbgJ0RZ4 (ORCPT + 99 others); Tue, 27 Oct 2020 13:25:56 -0400 Received: from mail.kernel.org ([198.145.29.99]:54024 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752034AbgJ0Oxk (ORCPT ); Tue, 27 Oct 2020 10:53:40 -0400 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 4D5D9222C8; Tue, 27 Oct 2020 14:53:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1603810419; bh=OpLbOhOpLkgVcWBbkxBCA/veGdYFoU8WNyf0u5A4wjg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qG74gNjZbDB3n7jbIkjtepzA231BcEhXAudVGCLEfjcZoQI25ZtCEd9am03v9oW4T lcSa2dIAcBM1r0JPE3bviX4FJDLaWcU4UDL6RJyLpEBmbo4fSL8qkJgJFahSclvT1j u4RYNyOUsG2YrpfBcpXQzbLEdO/hTAdvMgoguncY= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Ryder Lee , Xiaoliang Pang , Herbert Xu , Sasha Levin Subject: [PATCH 5.8 132/633] cypto: mediatek - fix leaks in mtk_desc_ring_alloc Date: Tue, 27 Oct 2020 14:47:55 +0100 Message-Id: <20201027135528.879619638@linuxfoundation.org> X-Mailer: git-send-email 2.29.1 In-Reply-To: <20201027135522.655719020@linuxfoundation.org> References: <20201027135522.655719020@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: Xiaoliang Pang [ Upstream commit 228d284aac61283cde508a925d666f854b57af63 ] In the init loop, if an error occurs in function 'dma_alloc_coherent', then goto the err_cleanup section, after run i--, in the array ring, the struct mtk_ring with index i will not be released, causing memory leaks Fixes: 785e5c616c849 ("crypto: mediatek - Add crypto driver support for some MediaTek chips") Cc: Ryder Lee Signed-off-by: Xiaoliang Pang Signed-off-by: Herbert Xu Signed-off-by: Sasha Levin --- drivers/crypto/mediatek/mtk-platform.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/crypto/mediatek/mtk-platform.c b/drivers/crypto/mediatek/mtk-platform.c index ef4339e84d034..efce3a83b35a8 100644 --- a/drivers/crypto/mediatek/mtk-platform.c +++ b/drivers/crypto/mediatek/mtk-platform.c @@ -469,13 +469,13 @@ static int mtk_desc_ring_alloc(struct mtk_cryp *cryp) return 0; err_cleanup: - for (; i--; ) { + do { dma_free_coherent(cryp->dev, MTK_DESC_RING_SZ, ring[i]->res_base, ring[i]->res_dma); dma_free_coherent(cryp->dev, MTK_DESC_RING_SZ, ring[i]->cmd_base, ring[i]->cmd_dma); kfree(ring[i]); - } + } while (i--); return -ENOMEM; } -- 2.25.1