]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/commitdiff
drm/nouveau: Fix runtime PM leak in drm_open()
authorLyude Paul <lyude@redhat.com>
Thu, 12 Jul 2018 17:02:52 +0000 (13:02 -0400)
committerJuerg Haefliger <juergh@canonical.com>
Wed, 24 Jul 2019 01:49:18 +0000 (19:49 -0600)
BugLink: https://bugs.launchpad.net/bugs/1836117
[ Upstream commit 922a8c82fafdec99688bbaea6c5889f562a42cdc ]

Noticed this as I was skimming through, if we fail to allocate memory
for cli we'll end up returning without dropping the runtime PM ref we
got. Additionally, we'll even return the wrong return code! (ret most
likely will == 0 here, we want -ENOMEM).

Signed-off-by: Lyude Paul <lyude@redhat.com>
Reviewed-by: Lukas Wunner <lukas@wunner.de>
Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
Signed-off-by: Kleber Sacilotto de Souza <kleber.souza@canonical.com>
drivers/gpu/drm/nouveau/nouveau_drm.c

index 070ceb601ef1ae049d52c238dfadb8e1212e16d1..bef5f86d51db7510e2437ccd056ff7383639024e 100644 (file)
@@ -954,8 +954,10 @@ nouveau_drm_open(struct drm_device *dev, struct drm_file *fpriv)
        get_task_comm(tmpname, current);
        snprintf(name, sizeof(name), "%s[%d]", tmpname, pid_nr(fpriv->pid));
 
-       if (!(cli = kzalloc(sizeof(*cli), GFP_KERNEL)))
-               return ret;
+       if (!(cli = kzalloc(sizeof(*cli), GFP_KERNEL))) {
+               ret = -ENOMEM;
+               goto done;
+       }
 
        ret = nouveau_cli_init(drm, name, cli);
        if (ret)