Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 20274008 authored by Markus Elfring's avatar Markus Elfring Committed by Daniel Vetter
Browse files

GPU-DRM: Use kmalloc_array() in drm_legacy_addbufs_pci()



A multiplication for the size determination of a memory allocation
indicated that an array data structure should be processed.
Thus use the corresponding function "kmalloc_array".

This issue was detected by using the Coccinelle software.

Signed-off-by: default avatarMarkus Elfring <elfring@users.sourceforge.net>
Signed-off-by: default avatarDaniel Vetter <daniel.vetter@ffwll.ch>
Link: http://patchwork.freedesktop.org/patch/msgid/b71c8fee-8e84-9f1b-8569-f1ae8b879cc5@users.sourceforge.net
parent 823d1bc1
Loading
Loading
Loading
Loading
+3 −2
Original line number Original line Diff line number Diff line
@@ -923,8 +923,9 @@ int drm_legacy_addbufs_pci(struct drm_device *dev,
	/* Keep the original pagelist until we know all the allocations
	/* Keep the original pagelist until we know all the allocations
	 * have succeeded
	 * have succeeded
	 */
	 */
	temp_pagelist = kmalloc((dma->page_count + (count << page_order)) *
	temp_pagelist = kmalloc_array(dma->page_count + (count << page_order),
			       sizeof(*dma->pagelist), GFP_KERNEL);
				      sizeof(*dma->pagelist),
				      GFP_KERNEL);
	if (!temp_pagelist) {
	if (!temp_pagelist) {
		kfree(entry->buflist);
		kfree(entry->buflist);
		kfree(entry->seglist);
		kfree(entry->seglist);