Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp311304pxk; Wed, 2 Sep 2020 23:39:03 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwk9YMCn6IrjsytbF+ufvXxkR+feY5jCHkz6xnFf2SAetEfKeph5QEC3vwrlO2DECPmNRCB X-Received: by 2002:a50:fc04:: with SMTP id i4mr1570074edr.14.1599115143432; Wed, 02 Sep 2020 23:39:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1599115143; cv=none; d=google.com; s=arc-20160816; b=RZ1bmTnScqY4hSD7l6/CTdER35nsoBMP32iKt9SonmJxTkNbyn8bQPJIoNEIDlBoaG uIBx0ydK4ejVutEJC5GWsnE/VN481WdO1vRPtEdqciAWYOI1rhq7gFgyS7b6wUUwq2G0 jE3FBB5FyNXOepalAEzgoa8Q3JgeQeY8fRmq0oIH2X6G/MwHoTSTLN9chZUPne9zjiB2 0CGCeJwokSuhgdox2QhULT7HtiaUxSpwegapoLdpM02zkNmOHqpJ37ck29NZNS8vge6d ghfsbqM7QnCrqujuB5xa4f24MUtgdijPhx9nhKq5YXPj20PgCiszGfDE3S+gbU+KsKyJ 56vA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature; bh=JzV2OCqdKiJejSLxD4j9h8uaxc1ywBPDynMdu8MGQD4=; b=BdQg4zME56t5KVvMqBh4nJQeCs6ktODMNIaktJLbyljFxyvl3wsYYx+LiU92+8JQb7 LeFoCFurlIb+I+YnxjIZpAfk+ZTT+ylB5QAJTLd4p6v9QjBWPdQDa5lh11srM5Xxk5RO SvvwtWMOy43ZkC64Z6GhuZWItn8s465uZxurjgi8LvBA8xyOlJmwmZXm/y/oEGy/Q952 wCD3WwBJ5i10xMp87HSXjyQ4wyv6iPpcEEivnr1cxG1gTAor5umVQEAmRLHyNy5Ck4Ck UCQSqUs5SWlYce+JorjBJZJ/k5wwYrT1fRzi75+dH36P74EDcFEYVIZ3gb6dE9d5alnM PtZA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=DjWvBbFY; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id i21si1089369edv.439.2020.09.02.23.38.27; Wed, 02 Sep 2020 23:39:03 -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; dkim=pass header.i=@gmail.com header.s=20161025 header.b=DjWvBbFY; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725967AbgICGiU (ORCPT + 99 others); Thu, 3 Sep 2020 02:38:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48228 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725943AbgICGiS (ORCPT ); Thu, 3 Sep 2020 02:38:18 -0400 Received: from mail-pg1-x544.google.com (mail-pg1-x544.google.com [IPv6:2607:f8b0:4864:20::544]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6AA0BC061244; Wed, 2 Sep 2020 23:38:18 -0700 (PDT) Received: by mail-pg1-x544.google.com with SMTP id e33so1325018pgm.0; Wed, 02 Sep 2020 23:38:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=JzV2OCqdKiJejSLxD4j9h8uaxc1ywBPDynMdu8MGQD4=; b=DjWvBbFYKTwUUrwMgdbDVts6nrIF8n3LkmmGUcaTH6wk12ytUSDtsZbPyPNZ7KhN0f BrB1VJ4PEHIvsRS6C9N2moXz/bDtABmEyI3AN4Nt6Yp91seZ5xzZmjU/cfyK4x26Dsw+ bU7Zwt6alhzP2UPw44N2BYQugdPZtbIw1HkAhXu50B+589L36cVRG9L/zQQEoVlH1hH8 sD7UCa+ohys2MGiDwRKvy/xmF54NLOiSwGmHaKLi8NmK0zKrXjKe6iAn85M4ELq4CwM1 gdCLz/M2tozNB8PHn8c+Krhkcve81QtjPMp8JNJ/NAURYpCDvdkLGY/Fk/THyWnsJe/z NieQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=JzV2OCqdKiJejSLxD4j9h8uaxc1ywBPDynMdu8MGQD4=; b=T3V+1MFICDl3q1+So/L9ZxAdPAecFlG3MZT102YlrmPuUg8a5CSc+8mVw10o9CIiYA tQ15Tx5DPHuV7L1QUPnIY9G+h9fu5StUcO4PvoMFkAfQW2LgpREfteTU0CAuEAV+3DCz xyOoYy7xNzfc4b+yZLC6DaO0zTxjumZ1/E/v8nJYVtn3GkZkYQSTLggXRtHNu4PGxkIS mhvIugZnAHs+YeiAWm0xpo9vGwLqINWLxgqF2lnlv8BGCiMt2HnuGrkhnVk29HaMf/Gl q2ClVyu0QLQ3PzkcRAgtdqUT7ffCq0E9JFnHxsVpioMBK69LC054shMspLnuoZQwuO+z VI0w== X-Gm-Message-State: AOAM532Xp0sry40UI5ZnORG14FYJviQY9zh20p9U4EbOBMSoyWdDOsdz jzSnkCOnkYjAfSSJHsUI2yI= X-Received: by 2002:a63:8448:: with SMTP id k69mr1697129pgd.69.1599115097868; Wed, 02 Sep 2020 23:38:17 -0700 (PDT) Received: from localhost.localdomain ([218.247.215.252]) by smtp.gmail.com with ESMTPSA id e123sm1754835pfh.167.2020.09.02.23.38.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Sep 2020 23:38:17 -0700 (PDT) From: Xiaoliang Pang To: herbert@gondor.apana.org.au, davem@davemloft.net, matthias.bgg@gmail.com, swboyd@chromium.org, yuehaibing@huawei.com, tianjia.zhang@linux.alibaba.com, ryder.lee@mediatek.com Cc: linux-crypto@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, linux-kernel@vger.kernel.org, dawning.pang@gmail.com Subject: [PATCH] cypto: mediatek - fix leaks in mtk_desc_ring_alloc Date: Thu, 3 Sep 2020 14:38:00 +0800 Message-Id: <20200903063800.27288-1-dawning.pang@gmail.com> X-Mailer: git-send-email 2.17.1 Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org In the init loop, if an error occurs in function 'dma_alloc_coherent', then goto the err_cleanup section, in the cleanup loop, after run i--, the struct mtk_ring rising[i] will not be released, causing a memory leak Signed-off-by: Xiaoliang Pang --- drivers/crypto/mediatek/mtk-platform.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/crypto/mediatek/mtk-platform.c b/drivers/crypto/mediatek/mtk-platform.c index 7e3ad085b5bd..05d341e4a696 100644 --- a/drivers/crypto/mediatek/mtk-platform.c +++ b/drivers/crypto/mediatek/mtk-platform.c @@ -469,7 +469,7 @@ static int mtk_desc_ring_alloc(struct mtk_cryp *cryp) return 0; err_cleanup: - for (; i--; ) { + for (; i >= 0; --i) { 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, -- 2.17.1