Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp3385576pxb; Mon, 17 Jan 2022 19:16:31 -0800 (PST) X-Google-Smtp-Source: ABdhPJxQjgOvvJiXJQ6XoFnzueD3XMhQUqBlg7GUK2pfjTHa9cDtenyi7lDWtpAu0N7AObZtVnkS X-Received: by 2002:a17:902:9f97:b0:14a:b594:7913 with SMTP id g23-20020a1709029f9700b0014ab5947913mr9214259plq.111.1642475790812; Mon, 17 Jan 2022 19:16:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1642475790; cv=none; d=google.com; s=arc-20160816; b=dTyX6G2EyAHL5fgLJm3DUAE5gO8BkpWnLexKf0OOpYIQJNSugFDeO5dVXrIIoA/Ehm cGQJJECKQAazrOBX9Bcnjm1ZeF8/+yuO3Tz9l16uO6QzOCOsuzzvQyWsnbDUciFkCcMS oWClZfgbv8m02EpCO1Wu1RranON9HafBoaKnSy8ceAQ8CBA6oq2vJ+JnqAB5CPfnxPeU euhpGuzdthwitosdzU+Wl3yNoyyKjJLu3208cq6cZP/wnVFr3GxYKrGVBUWZxqM+zGHF FLsf5Gt3wu8YYn96nl9b+MuR9OpWNPHhQl6qPmLjTq0EHGcWbxCtPPtd6rESfgga8lyy NW0Q== 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 :dkim-signature; bh=0F7RvCxmmHte011qN2EVdzrBB1K8t1Hpy7lMgXOcJxQ=; b=kX6sTrddf/zFcoRnDYTwxJtJtBmbA27Cz63y9ZpkrqFQizGY8p1TsiLNmSDcLpBpK3 NCv6Qz44/ckCNy/WYmV4G0Vemvq9s0cuG7FKZ/4ZBbhOCl8VQM63OLW6QbzLCEZxVwwK uwRD3vME1Mp6A720HKWh6PuP2IL5Df3bP4qw2/7S/1cLDJDrv/KvDz4gR/hAEzBrtuWL hjosLSby+HJ9Fl4V9Tc156kV+T7ZpZkLz7Ifev7RPHpnsbE/vdIKpM2/pRXeG+LI/Dzn s3GK43GQURrWBvwbaLLfJBXwwECBWCeDVgrwbw+40yqGDCSsi9lNc6pDw9F2s4LT6SJj w3GA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=ShGnzcfo; 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 u20si1164578pjr.84.2022.01.17.19.16.18; Mon, 17 Jan 2022 19:16:30 -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; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=ShGnzcfo; 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 S244793AbiARC0R (ORCPT + 99 others); Mon, 17 Jan 2022 21:26:17 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57132 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S245068AbiARCYS (ORCPT ); Mon, 17 Jan 2022 21:24:18 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 77CE5C061774; Mon, 17 Jan 2022 18:23:54 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 401C9B8123D; Tue, 18 Jan 2022 02:23:53 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2ACEBC36AEF; Tue, 18 Jan 2022 02:23:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1642472632; bh=6xvV/GFUTTbXguNm6jo1qvCc+irsly4Qs2GXu5oETWU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ShGnzcfog3KlRBshmhE/EnacItubBWvOBe5Gf0JR7lVZqJFxMg6thCBaWoG/eiHEP QzXvXNJ2g8U/UVqHwEByIyuPwb4Kq5TIsQNILQtj347gd7suX66j8txIBH2jFlMvYx Ko8btsQSS3fvhXRnjv6lJComZ8SpqidsAacc6BLGsIj0C4wpNigbfx4XqjMC1Nsq9A 9ZYJ7Th9e/dRJdilJRmZgszyX7Td4akDL6gCb8msVz3qxkhe8oBrihelVWgvZP6Ks4 B3EKMmE2fXj3oKdF/oiP/Uqpte0dQZmlbY0/sswUoO+NHczjxNHvDFrl6Po6uOxU4Y BfuzVpreZRZzQ== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Zack Rusin , Martin Krastev , Sasha Levin , linux-graphics-maintainer@vmware.com, airlied@linux.ie, daniel@ffwll.ch, dri-devel@lists.freedesktop.org Subject: [PATCH AUTOSEL 5.16 082/217] drm/vmwgfx: Release ttm memory if probe fails Date: Mon, 17 Jan 2022 21:17:25 -0500 Message-Id: <20220118021940.1942199-82-sashal@kernel.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220118021940.1942199-1-sashal@kernel.org> References: <20220118021940.1942199-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: Zack Rusin [ Upstream commit 28b5f3b6121b7db2a44be499cfca0b6b801588b6 ] The ttm mem global state was leaking if the vmwgfx driver load failed. In case of a driver load failure we have to make sure we also release the ttm mem global state. Signed-off-by: Zack Rusin Reviewed-by: Martin Krastev Link: https://patchwork.freedesktop.org/patch/msgid/20211105193845.258816-3-zackr@vmware.com Signed-off-by: Sasha Levin --- drivers/gpu/drm/vmwgfx/vmwgfx_drv.c | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c index bfd71c86faa58..68f46f9e032dd 100644 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c @@ -1617,34 +1617,40 @@ static int vmw_probe(struct pci_dev *pdev, const struct pci_device_id *ent) ret = drm_aperture_remove_conflicting_pci_framebuffers(pdev, &driver); if (ret) - return ret; + goto out_error; ret = pcim_enable_device(pdev); if (ret) - return ret; + goto out_error; vmw = devm_drm_dev_alloc(&pdev->dev, &driver, struct vmw_private, drm); - if (IS_ERR(vmw)) - return PTR_ERR(vmw); + if (IS_ERR(vmw)) { + ret = PTR_ERR(vmw); + goto out_error; + } pci_set_drvdata(pdev, &vmw->drm); ret = ttm_mem_global_init(&ttm_mem_glob, &pdev->dev); if (ret) - return ret; + goto out_error; ret = vmw_driver_load(vmw, ent->device); if (ret) - return ret; + goto out_release; ret = drm_dev_register(&vmw->drm, 0); - if (ret) { - vmw_driver_unload(&vmw->drm); - return ret; - } + if (ret) + goto out_unload; return 0; +out_unload: + vmw_driver_unload(&vmw->drm); +out_release: + ttm_mem_global_release(&ttm_mem_glob); +out_error: + return ret; } static int __init vmwgfx_init(void) -- 2.34.1