Received: by 2002:ab2:3350:0:b0:1f4:6588:b3a7 with SMTP id o16csp735521lqe; Sun, 7 Apr 2024 01:06:53 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCW7N7+Pi/vow5ggD8eemMpROxJeLJ1Sq4ChacGK5HPKEFSnMCWN2XVngLnoQ9udR3x2VSi7p/w9LyPG6OKuDmYx5/+tzuBVVf47/8/qZA== X-Google-Smtp-Source: AGHT+IF6+Sh4exN6Qi95r4A5L9EdwRGueI0lNMX0FkPoQwKg3H3cZeXWP7KtKi6/5/QGpcP0EL6x X-Received: by 2002:a50:8d15:0:b0:56e:ddc:17ad with SMTP id s21-20020a508d15000000b0056e0ddc17admr4739429eds.30.1712477213158; Sun, 07 Apr 2024 01:06:53 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712477213; cv=pass; d=google.com; s=arc-20160816; b=px3s8InEc754dev8dwVfd3B1XGfmz12yPpm+oPR/N3R2AbdIMr7L6XtJUaTiLtZIRr zs5HQQOg9Lgn+gxLf5zOrfB7+19aQVDOu1gi+kGbkxjuUF4PrnFYbTR+wu3eM9vBMFvK /bYZ2TVkOsqPzrChd073RUIwsc2jdW2CYC5DqKj+6FAPr8gMG1hk66k/MDo/zn5j/E6G IznVBVM8Dq/XCg0vN8y1S3Y3uBNOeNCc5Hm6mQMIemXDr94M92bg9b2OztXAKFHVvTdZ EwmU04BrCFtcscY9saH0g5ZjxcmNAB2fWCCXICtlmxqgeJfW7B5Q2aX5Kgcmd5Hkgm7W UxYQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from; bh=bTn0QhfMiwG5Hjxw3c4lU1Yei2o0KlKsLrIJsBUSs6I=; fh=VzMToBYo5MUfLaQO74C2Chjt/otG4r80qnd7ynZ/RBQ=; b=OTXwTPrhEvxuLM1AuAptVN1TJHbQx5nuJ0Z3bQ9Ccw04G8EV7u3t724ZM9XtiSv542 4k9YHjILXgabx15tZByDxynAICuRybOQdp6SfaLkDfj2YPhNMS6AnjEl1DPXr0l+AYGL 9LjvOBlXo29UbUObrW3DCJEieRNGG1qKeQ4NSTILBo20+y58C82szLIrs0bIwxu6oS5b pguk42y0rY2hqzC6tP7G2nF4zgVA+Fxd0ajMuhT9syXO7itm6NdNU40qUZiO0vOgQVfG ZDqgy/mGDD7hyhEOoesV2UDJjovJ2TYgYxVhRep8zgZF1KSh6Yk04zRd4bzNyJ/1MkPC ffgg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=huawei.com dmarc=pass fromdomain=huawei.com); spf=pass (google.com: domain of linux-crypto+bounces-3390-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-crypto+bounces-3390-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id dm10-20020a170907948a00b00a51a4052df1si2598569ejc.569.2024.04.07.01.06.53 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 07 Apr 2024 01:06:53 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-crypto+bounces-3390-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=huawei.com dmarc=pass fromdomain=huawei.com); spf=pass (google.com: domain of linux-crypto+bounces-3390-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-crypto+bounces-3390-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id DE55C1F222DF for ; Sun, 7 Apr 2024 08:06:52 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 6BF911096F; Sun, 7 Apr 2024 08:04:45 +0000 (UTC) X-Original-To: linux-crypto@vger.kernel.org Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 882472D607; Sun, 7 Apr 2024 08:04:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.249.212.187 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712477085; cv=none; b=RlZ6cYRp49H/dncuhWN2nuiApW4foPukQEtgt4q+qE/gkwnpzcYBr83DzkVunNGPhziIcjsVnErxxwu4LGz2VclOYlAgQ1EY8ndaeP5bgaSm9oknBCxGh56enfIRlJEVqzIeiiGN7/ceWQfOK3CbhtX9JGvyCPg0OlmQgFAC38s= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712477085; c=relaxed/simple; bh=CdhX2Ap1YEFlm/vZA7QzJ/ST39fvUSFJOa1MFzbeuBM=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=QIPJzHrKq/5lBppGwDB4kD2PYvYpezabyGCe+UAs0ohhodR/6yR6IVWCgx18HnMHiBgJFJVo6tk2+2B9O2XX+uGNIEEr24pPgLp8KdpewCZdw1ZVlzKq50D34WY8LtO9R/hk7fVvo7ssLv4Y7MWIoj23Q2W4MkGACGwsH7aAxpo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com; spf=pass smtp.mailfrom=huawei.com; arc=none smtp.client-ip=45.249.212.187 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huawei.com Received: from mail.maildlp.com (unknown [172.19.88.105]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4VC4SK3N5GztRtx; Sun, 7 Apr 2024 16:01:53 +0800 (CST) Received: from kwepemi500025.china.huawei.com (unknown [7.221.188.170]) by mail.maildlp.com (Postfix) with ESMTPS id D586A14010C; Sun, 7 Apr 2024 16:04:32 +0800 (CST) Received: from localhost.localdomain (10.67.165.2) by kwepemi500025.china.huawei.com (7.221.188.170) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.35; Sun, 7 Apr 2024 16:04:32 +0800 From: Chenghai Huang To: , CC: , , , , , , , , , , , Subject: [PATCH v2 7/9] crypto: hisilicon/sec - Fix memory leak for sec resource release Date: Sun, 7 Apr 2024 15:59:58 +0800 Message-ID: <20240407080000.673435-8-huangchenghai2@huawei.com> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20240407080000.673435-1-huangchenghai2@huawei.com> References: <20240407080000.673435-1-huangchenghai2@huawei.com> Precedence: bulk X-Mailing-List: linux-crypto@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: dggems701-chm.china.huawei.com (10.3.19.178) To kwepemi500025.china.huawei.com (7.221.188.170) The AIV is one of the SEC resources. When releasing resources, it need to release the AIV resources at the same time. Otherwise, memory leakage occurs. The aiv resource release is added to the sec resource release function. Signed-off-by: Chenghai Huang --- drivers/crypto/hisilicon/sec2/sec_crypto.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/crypto/hisilicon/sec2/sec_crypto.c b/drivers/crypto/hisilicon/sec2/sec_crypto.c index 93a972fcbf63..0558f98e221f 100644 --- a/drivers/crypto/hisilicon/sec2/sec_crypto.c +++ b/drivers/crypto/hisilicon/sec2/sec_crypto.c @@ -481,8 +481,10 @@ static void sec_alg_resource_free(struct sec_ctx *ctx, if (ctx->pbuf_supported) sec_free_pbuf_resource(dev, qp_ctx->res); - if (ctx->alg_type == SEC_AEAD) + if (ctx->alg_type == SEC_AEAD) { sec_free_mac_resource(dev, qp_ctx->res); + sec_free_aiv_resource(dev, qp_ctx->res); + } } static int sec_alloc_qp_ctx_resource(struct sec_ctx *ctx, struct sec_qp_ctx *qp_ctx) -- 2.30.0