Commit ea8c9ed5 authored by Zou Wei's avatar Zou Wei Committed by Daniel Vetter
Browse files

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: 70556e24 ("drm: remove usage of drm_pci_alloc/free")
Reported-by: default avatarHulk Robot <hulkci@huawei.com>
Signed-off-by: default avatarZou Wei <zou_wei@huawei.com>
Signed-off-by: default avatarDaniel Vetter <daniel.vetter@ffwll.ch>
Link: https://patchwork.freedesktop.org/patch/msgid/1621341302-112089-1-git-send-email-zou_wei@huawei.com
parent 808a4ae5
Loading
Loading
Loading
Loading
+9 −1
Original line number Diff line number Diff line
@@ -984,8 +984,16 @@ int drm_legacy_addbufs_pci(struct drm_device *dev,

	while (entry->buf_count < count) {
		dmah = kmalloc(sizeof(drm_dma_handle_t), GFP_KERNEL);
		if (!dmah)
		if (!dmah) {
			/* Set count correctly so we free the proper amount. */
			entry->buf_count = count;
			entry->seg_count = count;
			drm_cleanup_buf_error(dev, entry);
			kfree(temp_pagelist);
			mutex_unlock(&dev->struct_mutex);
			atomic_dec(&dev->buf_alloc);
			return -ENOMEM;
		}

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