Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp1929897pxu; Sun, 13 Dec 2020 07:56:30 -0800 (PST) X-Google-Smtp-Source: ABdhPJxQhFhvE36Kz29t9PUycMxcle8BeNhEviUDH7uNUatZ9ylPcy/GII7Upg24ftBHAZiE/bFp X-Received: by 2002:a17:906:adcb:: with SMTP id lb11mr18600346ejb.346.1607874990011; Sun, 13 Dec 2020 07:56:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1607874990; cv=none; d=google.com; s=arc-20160816; b=jBINGqgjx0+DWXAkI2ecpZmlUQ+IddQNsoS97A2u0PNrBvuB2w3Z9kp72CdQWuPBpe xcZinVJqiZ1P6ey7c7xq16Z5LAJBJ7IbP1V5WJMo4TN3X2LrXqKBbXsfBRSm/euc6BdQ v5qvkLMNHCuLLZ4a7nTqrrPxchU5WQTiO0MjNP/49DYFfkSJtTRcHUq4dTTYLnqME0lZ z0OoXBVFVScDzlMtHWg2OFESE/n7pOhlrOqQCoMugVvMA4Cn2f2R2PkStdAB5gJvTges B5bqd69NMu+nIB8WXaS0sJ6grakJdaAJI3vhMZnJLvC6nQvfvV6RaUniofweZhnXY0P7 OGDw== 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 :references:in-reply-to:message-id:date:subject:cc:to:from; bh=l6QupbB0uiuVNlxvo1Ht/1aPxUrTs218Y70XVkqz9Q4=; b=Nx3e5e33dry5bjgaoStOTpA24pUxrgED/lfY3txrSMgah2Ocya5wtI6tF0P6UjqQsW aPN6+RNd3JH2VxFl2tdU/d8zTxvlmyRTeYd32yX8y/pUWwGJ3lATE/LXUlmqtvwdeY1p 6uGK/1fPqR+7vDEoYU3FOeLkLeIdV64vrdLAvzNQiZxzzSyzHGuHCHXJ2wGxLJe2X60h k0rugFdo7Pm0i+3+4RarC6jCORIeN03IX1433mP9i8IlUTnuMLIl756P6VGAIIC2lSld 57cI+De+TXOCW9P102EuyibO2Hsg+S7lgPG9ZARUrFLfXgb8VZWng1or/+FNjEhoDuyo CQuw== ARC-Authentication-Results: i=1; mx.google.com; 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=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id o4si7611812ejr.495.2020.12.13.07.56.07; Sun, 13 Dec 2020 07:56:29 -0800 (PST) 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; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2439448AbgLLQKa (ORCPT + 99 others); Sat, 12 Dec 2020 11:10:30 -0500 Received: from mail.kernel.org ([198.145.29.99]:57726 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2439376AbgLLQJg (ORCPT ); Sat, 12 Dec 2020 11:09:36 -0500 From: Sasha Levin Authentication-Results: mail.kernel.org; dkim=permerror (bad message/signature format) To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Ofir Bitton , Oded Gabbay , Sasha Levin Subject: [PATCH AUTOSEL 5.9 10/23] habanalabs: free host huge va_range if not used Date: Sat, 12 Dec 2020 11:07:51 -0500 Message-Id: <20201212160804.2334982-10-sashal@kernel.org> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20201212160804.2334982-1-sashal@kernel.org> References: <20201212160804.2334982-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Ofir Bitton [ Upstream commit c8c39fbd01d42c30454e42c16bcd69c17260b90a ] If huge range is not valid, driver uses the host range also for huge page allocations, but driver never frees its allocation. This introduces a memory leak every time a user closes its context. Signed-off-by: Ofir Bitton Reviewed-by: Oded Gabbay Signed-off-by: Oded Gabbay Signed-off-by: Sasha Levin --- drivers/misc/habanalabs/common/memory.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/misc/habanalabs/common/memory.c b/drivers/misc/habanalabs/common/memory.c index 5ff4688683fd3..7b839189c0161 100644 --- a/drivers/misc/habanalabs/common/memory.c +++ b/drivers/misc/habanalabs/common/memory.c @@ -1616,6 +1616,7 @@ static int vm_ctx_init_with_ranges(struct hl_ctx *ctx, goto host_hpage_range_err; } } else { + kfree(ctx->host_huge_va_range); ctx->host_huge_va_range = ctx->host_va_range; } -- 2.27.0