Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp4600322pxj; Wed, 12 May 2021 09:01:16 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyCgr+8bm/8WriqOtCAlNIDzBq5WfqUEm+A7onifRdbTHgDN91+lBVfMP9VPRiPAp7EmoVO X-Received: by 2002:a05:6402:849:: with SMTP id b9mr30209336edz.126.1620835276466; Wed, 12 May 2021 09:01:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620835276; cv=none; d=google.com; s=arc-20160816; b=hOHPxEDJbGthTcZ0lm0ex+n33dGAFjs5Bxh2l1RzOQaG8vLz0JcixUhE63tkHojr0a +s6zOsfD/UujAzCi83C5VKMbukwzex9zaM/uOJCS/Y3Uhyk39Y3pAmKWkoCdEUEVuKJQ phGoGdvEbLm/iHSUa9t+CCJ2+N5Rl7ZfcBfO6VS3sOaKeoKfTkMjMoyMCEPlm/ioapFi xrjIu8cWZLj0lcQXSPaQ7lxGnDlGyq2WNpM+SIJ7tbE3+exzDdZbZtXTw/LpCXCDQRo7 +QMk+aBqFmYsYsVvLOBDxlIdBMKaW/VroYj93Io9nb5GSCTbuVHJSBar+B+sk2WV3zuR Tiug== 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=Yw2taYlyr8GmlhsrXkkAZPaqReeKZ2rgFvFZfCyG3vg=; b=EV+UcMqpTLWrkgBa0wKkfebJrVZhQjbwF/FrBcZn9vuq0TpaEf77TMSWrakzNR1ZdP u64Nx6wYWTNBgFng07LFvkbQwtle1Qm+Z62kUUhy5opEe8zv3GbokyImbRLN8ua+Oylb NWGrrUGMsmSgfyVzq5mMCEmYvB4zyPZSPZ4SGyAMyLZgDvsUXKUqnYHdXTsLEuNSL0/T ZGM3UYrwpVnKn/9uByP7c2OZkSwLFJIzF83Z6kN0Pb1wh0H4DLFc7zsrtcxDykQe0FKt w4N8Wi8bstAVtWCp4ah4IZXB0plvr8qVwjJhgJfYYNiLTKuc0pSLhfPSwgT/abQQGIUY mqwA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=ydIkueQF; 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 y9si94583edd.548.2021.05.12.09.00.50; Wed, 12 May 2021 09:01:16 -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=ydIkueQF; 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 S237669AbhELP4G (ORCPT + 99 others); Wed, 12 May 2021 11:56:06 -0400 Received: from mail.kernel.org ([198.145.29.99]:38784 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235148AbhELP04 (ORCPT ); Wed, 12 May 2021 11:26:56 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id CC61761A0F; Wed, 12 May 2021 15:11:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1620832310; bh=GrDk/zsa2GMA97HFS9gxyKbTjbhNFRNPg2EHVtDo/N4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ydIkueQFvcZcxq01KoFHr2kRTJd85VctD6/kdIxhpr+SXtNpQuDBY300ech2Jb8sO BJVlcrKrsVZ1yOJuDO6Hcp+uXfF3nQWJKxH6LeK2n43gCsCoRMfjQEn23ZIW7UfpCs CszCwBWV2YC5b+2P+REhbWGMpi0r2z/MpKH6GcHs= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Colin Ian King , Herbert Xu , Sasha Levin Subject: [PATCH 5.10 228/530] crypto: sa2ul - Fix memory leak of rxd Date: Wed, 12 May 2021 16:45:38 +0200 Message-Id: <20210512144827.322331687@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 854b7737199848a91f6adfa0a03cf6f0c46c86e8 ] There are two error return paths that are not freeing rxd and causing memory leaks. Fix these. Addresses-Coverity: ("Resource leak") Fixes: 00c9211f60db ("crypto: sa2ul - Fix DMA mapping API usage") Signed-off-by: Colin Ian King Signed-off-by: Herbert Xu Signed-off-by: Sasha Levin --- drivers/crypto/sa2ul.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/crypto/sa2ul.c b/drivers/crypto/sa2ul.c index 39d56ab12f27..4640fe0c1f22 100644 --- a/drivers/crypto/sa2ul.c +++ b/drivers/crypto/sa2ul.c @@ -1138,8 +1138,10 @@ static int sa_run(struct sa_req *req) mapped_sg->sgt.sgl = src; mapped_sg->sgt.orig_nents = src_nents; ret = dma_map_sgtable(ddev, &mapped_sg->sgt, dir_src, 0); - if (ret) + if (ret) { + kfree(rxd); return ret; + } mapped_sg->dir = dir_src; mapped_sg->mapped = true; @@ -1147,8 +1149,10 @@ static int sa_run(struct sa_req *req) mapped_sg->sgt.sgl = req->src; mapped_sg->sgt.orig_nents = sg_nents; ret = dma_map_sgtable(ddev, &mapped_sg->sgt, dir_src, 0); - if (ret) + if (ret) { + kfree(rxd); return ret; + } mapped_sg->dir = dir_src; mapped_sg->mapped = true; -- 2.30.2