Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

drm/amdgpu: Fix PCI device refcount leak in amdgpu_atrm_get_bios()

As comment of pci_get_class() says, it returns a pci_device with its
refcount increased and decreased the refcount for the input parameter
@from if it is not NULL.

If we break the loop in amdgpu_atrm_get_bios() with 'pdev' not NULL, we
need to call pci_dev_put() to decrease the refcount. Add the missing
pci_dev_put() to avoid refcount leak.

Fixes: d38ceaf99ed0 ("drm/amdgpu: add core driver (v4)")
Signed-off-by: Xiongfeng Wang <wangxiongfeng2@huawei.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>

authored by

Xiongfeng Wang and committed by
Alex Deucher
ca54639c abcb2ace

+1
+1
drivers/gpu/drm/amd/amdgpu/amdgpu_bios.c
··· 317 317 318 318 if (!found) 319 319 return false; 320 + pci_dev_put(pdev); 320 321 321 322 adev->bios = kmalloc(size, GFP_KERNEL); 322 323 if (!adev->bios) {