fbdev: vermilion: decrease reference count in error path
authorXiongfeng Wang <wangxiongfeng2@huawei.com>
Mon, 14 Nov 2022 08:56:54 +0000 (16:56 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 7 Jan 2023 11:07:27 +0000 (12:07 +0100)
[ Upstream commit 001f2cdb952a9566c77fb4b5470cc361db5601bb ]

pci_get_device() will increase the reference count for the returned
pci_dev. For the error path, we need to use pci_dev_put() to decrease
the reference count.

Fixes: dbe7e429fedb ("vmlfb: framebuffer driver for Intel Vermilion Range")
Signed-off-by: Xiongfeng Wang <wangxiongfeng2@huawei.com>
Signed-off-by: Helge Deller <deller@gmx.de>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/video/fbdev/vermilion/vermilion.c

index 1c1e95a0b8faa04006c857158c79ac11bc904d96..9774e9513ad0da1edf9ff987d1561ff869070b17 100644 (file)
@@ -291,8 +291,10 @@ static int vmlfb_get_gpu(struct vml_par *par)
 
        mutex_unlock(&vml_mutex);
 
-       if (pci_enable_device(par->gpu) < 0)
+       if (pci_enable_device(par->gpu) < 0) {
+               pci_dev_put(par->gpu);
                return -ENODEV;
+       }
 
        return 0;
 }