Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp3677739pxb; Mon, 24 Jan 2022 15:07:40 -0800 (PST) X-Google-Smtp-Source: ABdhPJw7Mr+8DCnSrMQpHA8+xzrL98pJajkzbsISuth6J3GsYWCotIZrEdh2hea8xjhMBLQ0suiU X-Received: by 2002:aa7:888d:0:b0:4c2:7965:950d with SMTP id z13-20020aa7888d000000b004c27965950dmr16121868pfe.46.1643065660571; Mon, 24 Jan 2022 15:07:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643065660; cv=none; d=google.com; s=arc-20160816; b=LCqr7u++gHHK3hXIYOhD8Auz0ye27Fs57ec8lTXxwzHfFFKXlry0JZexGHwiUuhQEf xUj+CwXYoH3oVytRBMlEoo36oLdJjpkMyY/g2udjiogqHdL2TEYRube3ophggLfrLEAn 1cmZM6qVCBOa1T7XJbWQFPk18slEJ8A1v9e9IsW5T0hpyUbyytFyfcA4ackaKx3SdiBR 9B2AonWDLuvqouB05Pxm4NAzT8Wd/zO7iULhK1St8aGJCRlSOGCrKgXUGTIAd47N7CGV yLki0c8cIKMjp9ZoumZVK2bImF1IolbRqRXKl/aV1KGcN0UeVUkJmTvAMuG22kqVr36m YVBg== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=MHZzmiwbbCXCIadGvV3nu9NJV1FLZTQtqnPNJT4whmo=; b=eaYP0EMLzS6SwdPGc/X/9zy6m7a3QMLYH6vkgpWy1IGJw+HntTT5gK8KDbcZRBmG4Q gnwJ6BKL1B7Cux0kHpKu4U9KtHDlr46V49TMOGFFiRr9kOywAeigLiBS9FI2pP1yjgrW Geu6Ftm/NkIH53M9QR1IW6Xo2gbO/z4P6Lsz6V9Um7c551euXdl3uyNX35CAD82vRMmG W83GZHTeQ5MIHDcdMAmCb8zGr9xIDr3HfypIyG/BFmIolgTd5TSyHfvjIb74/1KFlfLM /az1Pvu0Du40E0MdE9CJp/3MBq2RbD/0njXmXLTqf/+iELWq9SX+0ZlP8H1VKcu88j96 zfng== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=xk5WrO4n; 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=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id ju17si537131pjb.151.2022.01.24.15.07.28; Mon, 24 Jan 2022 15:07:40 -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=@linuxfoundation.org header.s=korg header.b=xk5WrO4n; 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=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1843267AbiAXXDk (ORCPT + 99 others); Mon, 24 Jan 2022 18:03:40 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58608 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1458062AbiAXVzH (ORCPT ); Mon, 24 Jan 2022 16:55:07 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1C285C07E2A8; Mon, 24 Jan 2022 12:37:00 -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 dfw.source.kernel.org (Postfix) with ESMTPS id B122961545; Mon, 24 Jan 2022 20:36:59 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7F804C340E5; Mon, 24 Jan 2022 20:36:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1643056619; bh=Hvvm+t8YuGPHPo5EwnXIPry3zfErMAu9pssWp8p3sPA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=xk5WrO4n7reerNIET6wZ8LDN/0wNAU4QeKR07mcnYQF5asrm9J8Rtk+wjwsP0+Jlk +N51m0wYCDj3pSFyR9z8wHEiSg1lFtppKm6SWf0k56GbrOgHv3ZmGXEAS+n88IMT9W hjJRmwjlKQ80keOWWCFhF/jZ4dL5d1ocIDmsNfAQ= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Zack Rusin , Martin Krastev , Sasha Levin Subject: [PATCH 5.15 511/846] drm/vmwgfx: Release ttm memory if probe fails Date: Mon, 24 Jan 2022 19:40:28 +0100 Message-Id: <20220124184118.645541205@linuxfoundation.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220124184100.867127425@linuxfoundation.org> References: <20220124184100.867127425@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 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 ab9a1750e1dff..8d0b083ba267f 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