Skip to content

Commit f00059b

Browse files
Philipp Stannerbjorn-helgaas
authored andcommitted
drm/vboxvideo: fix mapping leaks
When the PCI devres API was introduced to this driver, it was wrongly assumed that initializing the device with pcim_enable_device() instead of pci_enable_device() will make all PCI functions managed. This is wrong and was caused by the quite confusing PCI devres API in which some, but not all, functions become managed that way. The function pci_iomap_range() is never managed. Replace pci_iomap_range() with the managed function pcim_iomap_range(). Fixes: 8558de4 ("drm/vboxvideo: use managed pci functions") Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Philipp Stanner <[email protected]> Signed-off-by: Krzysztof Wilczyński <[email protected]> Signed-off-by: Bjorn Helgaas <[email protected]> Reviewed-by: Hans de Goede <[email protected]>
1 parent ad78e05 commit f00059b

File tree

1 file changed

+9
-11
lines changed

1 file changed

+9
-11
lines changed

drivers/gpu/drm/vboxvideo/vbox_main.c

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -42,12 +42,11 @@ static int vbox_accel_init(struct vbox_private *vbox)
4242
/* Take a command buffer for each screen from the end of usable VRAM. */
4343
vbox->available_vram_size -= vbox->num_crtcs * VBVA_MIN_BUFFER_SIZE;
4444

45-
vbox->vbva_buffers = pci_iomap_range(pdev, 0,
46-
vbox->available_vram_size,
47-
vbox->num_crtcs *
48-
VBVA_MIN_BUFFER_SIZE);
49-
if (!vbox->vbva_buffers)
50-
return -ENOMEM;
45+
vbox->vbva_buffers = pcim_iomap_range(
46+
pdev, 0, vbox->available_vram_size,
47+
vbox->num_crtcs * VBVA_MIN_BUFFER_SIZE);
48+
if (IS_ERR(vbox->vbva_buffers))
49+
return PTR_ERR(vbox->vbva_buffers);
5150

5251
for (i = 0; i < vbox->num_crtcs; ++i) {
5352
vbva_setup_buffer_context(&vbox->vbva_info[i],
@@ -116,11 +115,10 @@ int vbox_hw_init(struct vbox_private *vbox)
116115
DRM_INFO("VRAM %08x\n", vbox->full_vram_size);
117116

118117
/* Map guest-heap at end of vram */
119-
vbox->guest_heap =
120-
pci_iomap_range(pdev, 0, GUEST_HEAP_OFFSET(vbox),
121-
GUEST_HEAP_SIZE);
122-
if (!vbox->guest_heap)
123-
return -ENOMEM;
118+
vbox->guest_heap = pcim_iomap_range(pdev, 0,
119+
GUEST_HEAP_OFFSET(vbox), GUEST_HEAP_SIZE);
120+
if (IS_ERR(vbox->guest_heap))
121+
return PTR_ERR(vbox->guest_heap);
124122

125123
/* Create guest-heap mem-pool use 2^4 = 16 byte chunks */
126124
vbox->guest_pool = devm_gen_pool_create(vbox->ddev.dev, 4, -1,

0 commit comments

Comments
 (0)