lkml.org 
[lkml]   [2022]   [Jan]   [24]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[PATCH 5.16 0603/1039] drm/vmwgfx: Release ttm memory if probe fails
    Date
    From: Zack Rusin <zackr@vmware.com>

    [ 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 <zackr@vmware.com>
    Reviewed-by: Martin Krastev <krastevm@vmware.com>
    Link: https://patchwork.freedesktop.org/patch/msgid/20211105193845.258816-3-zackr@vmware.com
    Signed-off-by: Sasha Levin <sashal@kernel.org>
    ---
    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


    \
     
     \ /
      Last update: 2022-01-25 01:13    [W:2.658 / U:1.940 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site