Skip to contentSkip to conversation

drm/nouveau/fb: fix pci device refcount leak in nv1a_ram_new()

PATCH New Yang Yingliang 1 participant 1 message May 4, 2023

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drm/nouveau/fb: fix pci device refcount leak in nv1a_ram_new()

As comment of pci_get_domain_bus_and_slot() says, it returns a pci device with refcount increment, when finish using it, the caller must decrement the reference count by calling pci_dev_put(). So call it after using to avoid refcount leak.

Fixes 6ee738610f41 ("drm/nouveau: Add DRM driver for NVIDIA GPUs")
---
 drivers/gpu/drm/nouveau/nvkm/subdev/fb/ramnv1a.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/gpu/drm/nouveau/nvkm/subdev/fb/ramnv1a.c +2 -0
index 18241c6ba5fa..4d52a158f320 100644
@@ -51,6 +51,8 @@ nv1a_ram_new(struct nvkm_fb *fb, struct nvkm_ram **pram)
 		mib = ((mem >> 4) & 127) + 1;
 	}
 
+	pci_dev_put(bridge);
+
 	return nvkm_ram_new_(&nv04_ram_func, fb, NVKM_RAM_TYPE_STOLEN,
 			     mib * 1024 * 1024, pram);
 }
Signature · 1 line
2.25.1