]> git.baikalelectronics.ru Git - kernel.git/commitdiff
GPU-DRM: Use kmalloc_array() in drm_legacy_addbufs_pci()
authorMarkus Elfring <elfring@users.sourceforge.net>
Mon, 19 Sep 2016 15:07:06 +0000 (17:07 +0200)
committerDaniel Vetter <daniel.vetter@ffwll.ch>
Wed, 21 Sep 2016 11:24:27 +0000 (13:24 +0200)
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: Markus Elfring <elfring@users.sourceforge.net>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Link: http://patchwork.freedesktop.org/patch/msgid/b71c8fee-8e84-9f1b-8569-f1ae8b879cc5@users.sourceforge.net
drivers/gpu/drm/drm_bufs.c

index 32191513e82d040ea3756cc957115f9505606a1f..ed33f4362dfe7fbd1fecfd32813ceb231f7d7c86 100644 (file)
@@ -923,8 +923,9 @@ int drm_legacy_addbufs_pci(struct drm_device *dev,
        /* Keep the original pagelist until we know all the allocations
         * have succeeded
         */
-       temp_pagelist = kmalloc((dma->page_count + (count << page_order)) *
-                              sizeof(*dma->pagelist), GFP_KERNEL);
+       temp_pagelist = kmalloc_array(dma->page_count + (count << page_order),
+                                     sizeof(*dma->pagelist),
+                                     GFP_KERNEL);
        if (!temp_pagelist) {
                kfree(entry->buflist);
                kfree(entry->seglist);