Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp3707638pxb; Mon, 24 Jan 2022 15:58:12 -0800 (PST) X-Google-Smtp-Source: ABdhPJz/yc7fIkN9W734BSq0HbsDkNiSGkHECaWPSYpfw0OpmuK9vYwzLaIAmO0zIjl6QOMV94HN X-Received: by 2002:a62:33c7:0:b0:4bd:5aa4:1220 with SMTP id z190-20020a6233c7000000b004bd5aa41220mr15808805pfz.55.1643068692763; Mon, 24 Jan 2022 15:58:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643068692; cv=none; d=google.com; s=arc-20160816; b=TI4//UrYNZybj3sp4pg+nzgICFGJl6UufWoNDMvge1IeVgRS/exYvMVqxEGSl6wnQu wLSYZwcfCo61LQxmE39m574kFBF6gfBypj4lGImHucGnS5kYPNPugAr8HhBWWZI9hDaG GHi0CQjl3aSiY94R0Ky1sxtpWvvPVFXfZKvOn5dxlErBe5QsEIiYsDWo9q5TV+9M1iwZ g95dMq/JSF0WkJky9EP6c0b6qVIioWLW+qey0nl7wfh1tvzl1WGYgEPC485hQnC2mTvL EYw+n1VmItDJutcLuNVtG9DE/w7Egbqz9P+pER+wT/pjfmH2d9CJWu2JOZ23O4GgNMU7 RzaQ== 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=0F7RvCxmmHte011qN2EVdzrBB1K8t1Hpy7lMgXOcJxQ=; b=EfVuybd0TIGxKHwsenj3cHCvL5FjzhcRaIHzULwS5GGQOS9u0tpq1SL2cav5E7Z4Ms FLS00Sqsh1xpoReGS81rCqEZcb6upSbxCECHftsnv4tfGnBv5BoHcSewQSXMHmUpKVw7 dMfm1jogKqeusJgKepl8jWcufTL3tNbzAZ/btmA4SSP4MSohCpEj5RzmijLRAqa2fjN0 tEiZK3jhtBf2/YYzCT/QMUaemF05uxTEL1IqMVQEz0fYQQSg7O0Q0qS8zU6bwQg7ZbSz lko9315Yug3eml6UEQXvBcFdO/AiEJ7r3MRngW8kOFtnZPToBHmvLF50fua6zIUoAWZl 9KFg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="nK/ebRQa"; 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 pc9si704603pjb.67.2022.01.24.15.58.00; Mon, 24 Jan 2022 15:58:12 -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="nK/ebRQa"; 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 S2366979AbiAXXxy (ORCPT + 99 others); Mon, 24 Jan 2022 18:53:54 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49718 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1846131AbiAXXOa (ORCPT ); Mon, 24 Jan 2022 18:14:30 -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 55802C06176A; Mon, 24 Jan 2022 13:23:24 -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 1E8ABB8105C; Mon, 24 Jan 2022 21:23:23 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 390B6C340E4; Mon, 24 Jan 2022 21:23:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1643059401; bh=6xvV/GFUTTbXguNm6jo1qvCc+irsly4Qs2GXu5oETWU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=nK/ebRQaPOnh0FR5f4BetNJ6LJHAVowJIeBiAjObhg9yIqermBih771VvJL6VSIqZ XZoYkfBCkXCRC/xlvXuFBzZIt3jCqMXNsjlEnzOgSa0hs821zkdS6bviCQnqbJ+4T4 bMsQZpBVh6zmx07soLfCbUKiFJXNmvmcq2ubf0pg= 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.16 0603/1039] drm/vmwgfx: Release ttm memory if probe fails Date: Mon, 24 Jan 2022 19:39:52 +0100 Message-Id: <20220124184145.605920205@linuxfoundation.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220124184125.121143506@linuxfoundation.org> References: <20220124184125.121143506@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 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