From patchwork Mon Dec 26 20:47:17 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SF Markus Elfring X-Patchwork-Id: 9488807 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 28D0260839 for ; Mon, 26 Dec 2016 20:56:05 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 185071FF8E for ; Mon, 26 Dec 2016 20:56:05 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0A27D1FFBD; Mon, 26 Dec 2016 20:56:05 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A1E631FF8E for ; Mon, 26 Dec 2016 20:56:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755913AbcLZU4C (ORCPT ); Mon, 26 Dec 2016 15:56:02 -0500 Received: from mout.web.de ([212.227.15.4]:63138 "EHLO mout.web.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755835AbcLZU4A (ORCPT ); Mon, 26 Dec 2016 15:56:00 -0500 Received: from [192.168.1.2] ([77.182.133.191]) by smtp.web.de (mrweb003 [213.165.67.108]) with ESMTPSA (Nemesis) id 0MMEyj-1cT4I31nkz-007z89; Mon, 26 Dec 2016 21:47:22 +0100 Subject: [PATCH 3/8] [media] videobuf-dma-sg: Use kmalloc_array() in videobuf_dma_init_user_locked() To: linux-media@vger.kernel.org, Dave Hansen , Jan Kara , Javier Martinez Canillas , "Kirill A. Shutemov" , Lorenzo Stoakes , Mauro Carvalho Chehab , Michal Hocko , Sakari Ailus References: <9268b60d-08ba-c64e-1848-f84679d64f80@users.sourceforge.net> Cc: LKML , kernel-janitors@vger.kernel.org From: SF Markus Elfring Message-ID: Date: Mon, 26 Dec 2016 21:47:17 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.6.0 MIME-Version: 1.0 In-Reply-To: <9268b60d-08ba-c64e-1848-f84679d64f80@users.sourceforge.net> X-Provags-ID: V03:K0:D3W/Z3ryim+27I5gJ2lNGirzL4bX6ngBStjLpfZxf+F7/+9BSlT FcsipGUTLmQT7Z04r/1OSDYMUVXX/5mfRWUWrHbNv8Xa6pgSRvN6rNL0sYiEK1n9m5MTYSJ 1ElC+ULQAANKXIWVw3i71nuwqkW6mH58HTeOT4hyDhC1ZFg1Pq8ZMKLgHpAeiTuxHYcFX94 CEWW5aSpDEkCwMDCX8ULg== X-UI-Out-Filterresults: notjunk:1; V01:K0:l8JgW0LUnUc=:fE24YY6wE+1q9Ef6f1Arwf O+xV8h1Wkc38p4sZRPp5Tq5XT2Xbc48Dg3lpT5eaor3s501Ga2QAPmUOS8KC2Ud6gDahyzeNP aXNz7hlOHxg57LpL9Ae1+RnkOsDm71fcO6gMxypUnfp27+pEHAP2EGhAaXIDpg2ryvmGdR5Ct Xeb+Tsx4cSGNtzmMM+aeK7dC2Lz52XwKC6/pJJVmLvWjeQtuFSHAVjcI2KCAnkXsvcvKHcLol oCgYTTJn7Bg5sUgiKTi+pJMMomMJJ+7+SuD/OCHqbbFOmomLqXXYHK1IXjBAZ+VQvM4a5Vwe4 2hSH8v9e+aVdNnrNTDMoPF3cGtOLK5bMflsI7mo9oL618zKMgthFxWHH5EYTIYOzaBTVQoSzd yOBOg3qt3fTcr86uGbbhVpbdjfan8M803i2u7zn5GqsXEmq3Dz1Lf5i13KBwXkajHQ2jfHZYW SIx94n+cLWCrqAvPzOKwkZszC0/CUVUIQlUKV4ort5IF3CAtfcRdTsh86StBbcZSvluFXnq/D q7oXRt4SmezQHEGpnKznZgQMIyltYSEFHeWy7rMjdyxZtMjNAOOK2V4krrjKLV3kkpL7/naC6 5jUeRX2L/42qvr4To/hsZg7mCr56/IkByxELW9ifeu2cws3+15byBNdZauGfZTB9BgAUXBwhb RycB3dYQX7iTX/JIuAGJvDH8P8OAyOHGGchVabzL/vCBblaniZdC80qZoWY3KdHmmE2aopsC/ i+AYsZPc3vLNNWZWzDwZoT6EFq22m7DnvrNOyayNcwnhOI6UdccVLO2K8xc/lFzDZMrzg7diM Dnvmm8f Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Markus Elfring Date: Mon, 26 Dec 2016 19:46:56 +0100 * 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. * Replace the specification of a data type by a pointer dereference to make the corresponding size determination a bit safer according to the Linux coding style convention. Signed-off-by: Markus Elfring --- drivers/media/v4l2-core/videobuf-dma-sg.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/media/v4l2-core/videobuf-dma-sg.c b/drivers/media/v4l2-core/videobuf-dma-sg.c index ba63ca57ed7e..ab3c1f6a2ca1 100644 --- a/drivers/media/v4l2-core/videobuf-dma-sg.c +++ b/drivers/media/v4l2-core/videobuf-dma-sg.c @@ -175,7 +175,9 @@ static int videobuf_dma_init_user_locked(struct videobuf_dmabuf *dma, dma->offset = data & ~PAGE_MASK; dma->size = size; dma->nr_pages = last-first+1; - dma->pages = kmalloc(dma->nr_pages * sizeof(struct page *), GFP_KERNEL); + dma->pages = kmalloc_array(dma->nr_pages, + sizeof(*dma->pages), + GFP_KERNEL); if (NULL == dma->pages) return -ENOMEM;