Skip to content

Commit 7e1f8fc

Browse files
SamuelZOUdanvet
authored andcommitted
drm: Fix missing unlock and free on error in drm_legacy_addbufs_pci()
Add the missing unlock and free before return from function drm_legacy_addbufs_pci() in the error handling case. Fixes: 064342c ("drm: remove usage of drm_pci_alloc/free") Reported-by: Hulk Robot <hulkci@huawei.com> Signed-off-by: Zou Wei <zou_wei@huawei.com> Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch> Link: https://patchwork.freedesktop.org/patch/msgid/1621341302-112089-1-git-send-email-zou_wei@huawei.com
1 parent be6e193 commit 7e1f8fc

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

drivers/gpu/drm/drm_bufs.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -984,8 +984,16 @@ int drm_legacy_addbufs_pci(struct drm_device *dev,
984984

985985
while (entry->buf_count < count) {
986986
dmah = kmalloc(sizeof(drm_dma_handle_t), GFP_KERNEL);
987-
if (!dmah)
987+
if (!dmah) {
988+
/* Set count correctly so we free the proper amount. */
989+
entry->buf_count = count;
990+
entry->seg_count = count;
991+
drm_cleanup_buf_error(dev, entry);
992+
kfree(temp_pagelist);
993+
mutex_unlock(&dev->struct_mutex);
994+
atomic_dec(&dev->buf_alloc);
988995
return -ENOMEM;
996+
}
989997

990998
dmah->size = total;
991999
dmah->vaddr = dma_alloc_coherent(dev->dev,

0 commit comments

Comments
 (0)