Received: by 2002:ab2:6857:0:b0:1ef:ffd0:ce49 with SMTP id l23csp2382243lqp; Sun, 24 Mar 2024 16:58:36 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUbWSpyWArf/HydOxLd2s4OjoF/gjjVFRxfOiVW0Gbtb7E0TNnCdGSlnLknNvFoGrOuytKaQ89MeyTwXVkJxKJGLNWDL0z9+QIoBNXxXg== X-Google-Smtp-Source: AGHT+IEubPFkR3V7VSiQ3UjIMqLlT+7vPQuBzkztdpbPb9BHUu90FkV9Zbpn0jcr0Z+U0yqFmcYm X-Received: by 2002:a05:6a00:b43:b0:6e7:48e8:6aa4 with SMTP id p3-20020a056a000b4300b006e748e86aa4mr8098490pfo.15.1711324715948; Sun, 24 Mar 2024 16:58:35 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711324715; cv=pass; d=google.com; s=arc-20160816; b=BhiYGyJ7Ly3Agw+ugRr0Ob24xtWAloyVi/EaPnk1JjkaIZdBPpiZ1yd1hmBBe2VKuQ 9VzeA3blO5H+L/6l301enbP76w6RJr/tGC+wHQCwyaMOBW0Ok0Uv+3UxAQlqxM5LxgIG X0zK4ZuACcqUs7HEtGBZs6s+iMhBv2kTA77Fb8LkICjz+jKnlrp+WImZI3oN/A9Ke4nH maFrhhGd88/CaAU1SzGHyO7Xv4fHbUjbI6uDdoxqJ4AamLwoYSPIXrW/FYg/GjkTISdi nXqHxblj5x9g7r9bO74RZdWsmsYuKSdbiCyJYJEtbeN+dNfHFqpAqKc3vSXAG+Sfy18z bZxA== 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:dkim-signature; bh=WycBh8UdkOHzDYg4CqV2odJwSI6Tz2BCJwRb//jQLUw=; fh=lRtS0jrPQv+vWvZjhww1LcArf9EqbC3ob8GNlA74vlc=; b=qqfWGlNr5rDv57Oj0XZ7rkBoMBfaEl2xIhiRHXTJJ9LdadL6m4IE88jfkE8JWZ2Mj+ H4OOHeQ/voVzRpkEk0yddgOODdXvPXyEoeJshJkeBqHxoXmKOwJWiXyfpIra114oamqR +AMpVARif5tq0GtV2FRY1lrDDkBhRDkbr4AtTFGazDXCWF1yu/PV4rsrqiWrQm3i5DSk KKkrXydmAgs0jEM/e+z7W0tyJh9w4JE3IcQh0GP2fOUnK8yHgO3HAHmUdO8Fb+V7gbSz c/khk5G8dW/OEk4xTFzqW4Hoee7oJxwon4NKGfyO9GYQH8GshLquhCosY6PLKSFsTbPf bOSQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=FIY3k9U+; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-113252-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-113252-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id z21-20020a634c15000000b005f057f34455si1716782pga.242.2024.03.24.16.58.35 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 24 Mar 2024 16:58:35 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-113252-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=FIY3k9U+; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-113252-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-113252-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org 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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 459A7286E19 for ; Sun, 24 Mar 2024 23:54:33 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1A3B7186396; Sun, 24 Mar 2024 22:40:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="FIY3k9U+" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 3082A1870C6; Sun, 24 Mar 2024 22:40:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711320052; cv=none; b=OMbVDha95SNI1OSxicQ/MgVFMjuJGF/BpipvaHkLjATXRVZDKZHmpD6FhusPE2XA1d0oWc96VkTGyORpYEkVPtGto7oPxVrQsVPiWkA2Oz/AHkzZbixJU97Ik6b1UkfQD3c/VqZ1tIzGukPiAxsol1K5s98W3oieGuqlimF2Ass= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711320052; c=relaxed/simple; bh=Ke97hrXldFBxj8KzdI5VmMC+f8kuAT2CHHarl1iwKgY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=sBmpthEIbh/NLSqZO8cNlE5YnUA97q1fn3kwrddFLeyWaam8UKssHjTl+a28bQX1/d7s3CbdkcgFCtLJ+wntLqOP1HRGUzaJJJuYQ25oudbhveYnKcNTV5/FgmkSQoeY0m4Cm+e5Ep1n8uHvHJGkAQ5HtLTG9GHkBCwR8TyTAFA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=FIY3k9U+; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 75033C433F1; Sun, 24 Mar 2024 22:40:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1711320052; bh=Ke97hrXldFBxj8KzdI5VmMC+f8kuAT2CHHarl1iwKgY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=FIY3k9U+IcObwFrWPQXzhuPdwPXFruDCLUZ3fej3FXrEBkt1l8qPrqefxi8EigT5Z 33qjBfkVxDjSxpj8H1f2jBilZT5nUtVNuauQr/K2C2ZtKkaIVbsG8BrpFtFQNYfnZw mp9HjSoup2l/SKuT40ws/wwZmDWdYkd7NG0MGe1YMSxx41tlwkjeMj1/JIeYOuZpRw lHTEsHEYBdaHB2flai7DibouhVRv38WsEffiVYWoFsSB53qzkg6J61kRGzIsSxoK7c ayPX2lrqBhnomDqniyYafmw0OVxett6eRbuDBf52xmILg3LMB9D6fhc+Vkz8qh08PO PKzJxV49tt3qg== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Zhipeng Lu , Zack Rusin , Sasha Levin Subject: [PATCH 6.8 361/715] drm/vmwgfx: fix a memleak in vmw_gmrid_man_get_node Date: Sun, 24 Mar 2024 18:29:00 -0400 Message-ID: <20240324223455.1342824-362-sashal@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240324223455.1342824-1-sashal@kernel.org> References: <20240324223455.1342824-1-sashal@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit From: Zhipeng Lu [ Upstream commit 89709105a6091948ffb6ec2427954cbfe45358ce ] When ida_alloc_max fails, resources allocated before should be freed, including *res allocated by kmalloc and ttm_resource_init. Fixes: d3bcb4b02fe9 ("drm/vmwgfx: switch the TTM backends to self alloc") Signed-off-by: Zhipeng Lu Signed-off-by: Zack Rusin Link: https://patchwork.freedesktop.org/patch/msgid/20231204091416.3308430-1-alexious@zju.edu.cn Signed-off-by: Sasha Levin --- drivers/gpu/drm/vmwgfx/vmwgfx_gmrid_manager.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_gmrid_manager.c b/drivers/gpu/drm/vmwgfx/vmwgfx_gmrid_manager.c index ceb4d3d3b965a..a0b47c9b33f55 100644 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_gmrid_manager.c +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_gmrid_manager.c @@ -64,8 +64,11 @@ static int vmw_gmrid_man_get_node(struct ttm_resource_manager *man, ttm_resource_init(bo, place, *res); id = ida_alloc_max(&gman->gmr_ida, gman->max_gmr_ids - 1, GFP_KERNEL); - if (id < 0) + if (id < 0) { + ttm_resource_fini(man, *res); + kfree(*res); return id; + } spin_lock(&gman->lock); -- 2.43.0