Received: by 2002:ab2:6857:0:b0:1ef:ffd0:ce49 with SMTP id l23csp2489434lqp; Sun, 24 Mar 2024 23:15:33 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWmaEuaP+uq7bSHBy+VIdpl7dzMUIitN4RtsgX7ACyYJwyF5NTNLy76pz4z+ktdOht/wHMzmbmmH3x4UuTRHDb+MyP9Lz7doHDD6JikRQ== X-Google-Smtp-Source: AGHT+IGhRAaMo2RjeVPELbPJWnLOJJ6CwmrcQuz1yxnFqhofVvIXS6DIu1HiphKUESERRLege5uJ X-Received: by 2002:ac8:7e89:0:b0:431:43e0:824e with SMTP id w9-20020ac87e89000000b0043143e0824emr7366449qtj.25.1711347333498; Sun, 24 Mar 2024 23:15:33 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711347333; cv=pass; d=google.com; s=arc-20160816; b=BP93NqtQ9OIOBr2HU3QcjyhYIgsQKYLBk/ZFFmEJVSEBr1ABOgNoaH1PlDwJpD/B3K kP9GLz+WJGKCq4w02aklZSMQFJUQWKJTxX8U0Wl1DcQobmO6n9dGy54FIwi4UYjihhLU fmbJYQLsI8RmVoZLszQ/JVIeC38KEZDss1IPniH0o6HVwEh9FcdONkkNdiAkcGfXez4z K046IVQQu3jJppfcgqXM4jVwXMLa2qPJCDjUgCMhGe2KDsvPtgavJQJPp/EsZX/kKaxP aYUgrEWt1M0NPkh1YFWGT0FvNUlj2tayKAv17lm89AVkftdlHwcbPYxowE2yjEeqL0wL 2oig== 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=JcCOLtpn3TBN0k3FGgsEmjTZj2+WDsYDT19d3T/PY+g=; fh=lRtS0jrPQv+vWvZjhww1LcArf9EqbC3ob8GNlA74vlc=; b=vplTzzy41a4yzZIkNiRc1x7hc91ahCDjmiQVzJ7XvqpptOnnK1PIXMKSGCZFvpsOQO nISDQllru3ciJhfw7mlke2E7AKOcUD7O0l1mn6KAhJBJJXR47PNERpaAlcbu1wHF7yNa LZ3CnGPlZjwNUJEkT4Ut84EaiPJh8Zudb+BJ7g/RHxhZqzV3G6/OosGlk0Df1xB1vvJ6 R7lBrvJ0oWSNYLzEzMXCI8z15l/YAqXKgRd0e51Yk6tEwFZRgFpG5VcdiKTEBn3hr5qi 62m9ycUvCRvr78MI2DOPYGhcA1qHQe7XKmEscYsvPEUpy2uIKg6pRqp/9EuZFQvsZZJK q0yw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=eJurXDGZ; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-114536-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-114536-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id jd17-20020a05622a719100b00430b3a87b41si4794266qtb.757.2024.03.24.23.15.33 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 24 Mar 2024 23:15:33 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-114536-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=eJurXDGZ; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-114536-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-114536-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id D841D1C2C2FC for ; Mon, 25 Mar 2024 06:15:32 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1E4C013C90B; Sun, 24 Mar 2024 23:50:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="eJurXDGZ" 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 5917314A09D; Sun, 24 Mar 2024 23:16:07 +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=1711322169; cv=none; b=ulY9FPK1T6rrrFHON5FsclM0Vn2AUlkwwj6tmGYtAockmGHINsktFIo03e22NDaYqif5xiF4zSy/xoEf1dbGuXd6iVjMK0FSZJ5dv6xycZ+c1Oe03iS18LW4QzI1a760Pw03k855xRnI7pwHkHEu/GaxCPJ7f3euUKX/GNxqD24= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711322169; c=relaxed/simple; bh=YvAHdfBYNVMUAWyXxI/Q1L63eWCD+RlQtf3uzCgBk+0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=N26oLre7vYfrDXGL8/kZ3W00B92KRgqHq8EGeXEHkTwvBgvtpDaNX/nON1SjC1Ts4YjrYGu9M+NzbTuXvUaKH9UPurs2LNlxpuXppdfwpaEbQuQKZ2wPEXczmsR9b5OsMRAjq9E7wWL7ZUwdGi2FTdQv963UB23sbjQF5CxImBc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=eJurXDGZ; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 41F4FC43394; Sun, 24 Mar 2024 23:16:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1711322167; bh=YvAHdfBYNVMUAWyXxI/Q1L63eWCD+RlQtf3uzCgBk+0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=eJurXDGZhi9f1g6wvxe9+9eofFz0LytlmkM6orw8cVVv7vBziOGl59Xr66Xmi8W5t KWGCblMSYQ8LBVx+CaMhrtqOSX4w2XErdVR+Jsk+u4k2zIMZjA392OXuItURBXYhUY rGki4tiTRj3R5PmTc387PVjt0flnFvkISYsivuw900osh34xVj3oqk3b3Kl9JH9CPv UL/EUxc8bpl8vkiDK0iXnQrWZ+exQZzNjfSc2rgxL9W3yPQuT7DMC8b6CHOfgCHW3E ZLwYuuqnb6eJV1I/4yyqATpVLFoigTt0x7bjKF+9Ijf4iFQhzEMG3beRyAJI3nNK5H xdjfE1Z30b9nQ== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Zhipeng Lu , Zack Rusin , Sasha Levin Subject: [PATCH 6.1 246/451] drm/vmwgfx: fix a memleak in vmw_gmrid_man_get_node Date: Sun, 24 Mar 2024 19:08:42 -0400 Message-ID: <20240324231207.1351418-247-sashal@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240324231207.1351418-1-sashal@kernel.org> References: <20240324231207.1351418-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 60e3cc537f365..b9e5c8cd31001 100644 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_gmrid_manager.c +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_gmrid_manager.c @@ -65,8 +65,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