From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S965999AbcIVS5i (ORCPT ); Thu, 22 Sep 2016 14:57:38 -0400 Received: from mout.web.de ([212.227.15.4]:52855 "EHLO mout.web.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S938318AbcIVRhp (ORCPT ); Thu, 22 Sep 2016 13:37:45 -0400 Subject: [PATCH 05/14] GPU-DRM-TTM: Use kmalloc_array() in two more functions To: dri-devel@lists.freedesktop.org, Daniel Vetter , David Airlie , Emil Velikov References: <566ABCD9.1060404@users.sourceforge.net> <4d34446f-05ad-c3ce-5d33-8fb4f25af25c@users.sourceforge.net> Cc: LKML , kernel-janitors@vger.kernel.org, Julia Lawall From: SF Markus Elfring Message-ID: <050b05d3-60ad-3768-8519-3ea37c34b188@users.sourceforge.net> Date: Thu, 22 Sep 2016 19:37:37 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.3.0 MIME-Version: 1.0 In-Reply-To: <4d34446f-05ad-c3ce-5d33-8fb4f25af25c@users.sourceforge.net> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Provags-ID: V03:K0:JPgIMTcGsJNMewG2YE/WCklLWYCVvnaeH1wrcIMCwDymANoYir8 LLT0X0fYnwBNXfgXlGeG/BDAKZLGxxRtepbWxDjOcf2Ekv7qtPa9bZ1PfUrdzQh56T4vZDM Wlzeo/n1yIa4PSbwKgIrzUackJC88ws5KrvWle/88E5/ab0UwMKeCXrtdTFXqyScaZTiMBn AIzhwUWWFXjFJhPxY4qqg== X-UI-Out-Filterresults: notjunk:1;V01:K0:nGwTdl3Iydc=:pt7p7kg6eCrU4KfUy7OURY YBByuVH0UKhmcjDdX3FaQhCyarprFFgfcSaJljEgNAtobw5Fw1UN4ttb8gaSalXLP/ECT+tbH cJlx33w3kOLTcpgAB6dAHZV2o/cV5U7w676g0EUuQq5/ajl2K8gxHDdtflBpe56xNMvTGs9M2 LM7GRh/HzgHl3JHe0n+FgqQIsjlj6B0g0efeq/zmzrSDvXGYqavC6MfQMAPgqvd0Qn2ij9FfH S5nGok5oplrJQD//1OSLQUkqI3Do0OvOFLVh7DFII2UvMMNtmYFo6Y/gIX2udH86IwLg3kq3l kFWbyZvRyFU1MkKP/DIOAJHb/saJEbS83Yqrp26OT6V5tQrczysYsPNp0hgpMubaJPLBVQ6Vn QY08igq/DmP6dTcHqgRAEJdRMIffJB0Or/DYRhtHbmPn3xNzGFJ7x58NLdXJrd9CnGVUcSVCk HjS+UIutk3Meom5VH0kgUV9cH69w/oemFx8jYRe6wCwj42F1SNpGOY2V3oiSAeH+D5Y5Fp+U5 NeQC4SC6R68uCJNOODqxtjyLOtcfhLZI3voQ0IMTqWa40bIHuQRN7tYCBvsmrNJjYdIFs2tJ2 6Wf7B0P3SRvVueuhoORsNeXQLW9m0JXcC9K5YkQgzjxfkqtwyU7/KEjnuQnqx8EquUs/lrCo5 KMN+S2Hy1qPqqg9kWwTzwI9i0H+w1+r/tk/pNYuGmQdKXw6emtlNzQdNdezHAaUXAf/Bgbr+g CUoFC/jz56Q6yas5tm9ckQ1cO8RfRLKWSYZcmGoelATtCjXsLPUYtT3vXE+0rFPkVxc6MuDYT GDolv8a Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Markus Elfring Date: Thu, 22 Sep 2016 14:48:39 +0200 * Multiplications for the size determination of memory allocations indicated that array data structure should be processed. Thus use the corresponding function "kmalloc_array". This issue was detected by using the Coccinelle software. * Replace the specification of data types by pointer dereferences to make the corresponding size determination a bit safer according to the Linux coding style convention. Signed-off-by: Markus Elfring --- drivers/gpu/drm/ttm/ttm_page_alloc_dma.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/drm/ttm/ttm_page_alloc_dma.c b/drivers/gpu/drm/ttm/ttm_page_alloc_dma.c index bef9f6f..194818d 100644 --- a/drivers/gpu/drm/ttm/ttm_page_alloc_dma.c +++ b/drivers/gpu/drm/ttm/ttm_page_alloc_dma.c @@ -439,8 +439,9 @@ static unsigned ttm_dma_page_pool_free(struct dma_pool *pool, unsigned nr_free, if (use_static) pages_to_free = static_buf; else - pages_to_free = kmalloc(npages_to_free * sizeof(struct page *), - GFP_KERNEL); + pages_to_free = kmalloc_array(npages_to_free, + sizeof(*pages_to_free), + GFP_KERNEL); if (!pages_to_free) { pr_err("%s: Failed to allocate memory for pool free operation\n", @@ -726,8 +727,9 @@ static int ttm_dma_pool_alloc_new_pages(struct dma_pool *pool, (unsigned)(PAGE_SIZE/sizeof(struct page *))); /* allocate array for page caching change */ - caching_array = kmalloc(max_cpages*sizeof(struct page *), GFP_KERNEL); - + caching_array = kmalloc_array(max_cpages, + sizeof(*caching_array), + GFP_KERNEL); if (!caching_array) { pr_err("%s: Unable to allocate table for new pages\n", pool->dev_name); -- 2.10.0