From patchwork Thu Dec 22 19:58:51 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: 9485523 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 535E5600BA for ; Thu, 22 Dec 2016 19:59:22 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 528D22843B for ; Thu, 22 Dec 2016 19:59:22 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4780F28456; Thu, 22 Dec 2016 19:59:22 +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 E75A52843B for ; Thu, 22 Dec 2016 19:59:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S966793AbcLVT7C (ORCPT ); Thu, 22 Dec 2016 14:59:02 -0500 Received: from mout.web.de ([212.227.15.14]:58745 "EHLO mout.web.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1761594AbcLVT7B (ORCPT ); Thu, 22 Dec 2016 14:59:01 -0500 Received: from [192.168.1.2] ([77.181.37.100]) by smtp.web.de (mrweb002 [213.165.67.108]) with ESMTPSA (Nemesis) id 0MhDRB-1byTtM3cif-00MLNH; Thu, 22 Dec 2016 20:58:54 +0100 Subject: [PATCH 1/2] [media] pvrusb2-io: Use kmalloc_array() in pvr2_stream_buffer_count() To: linux-media@vger.kernel.org, Mauro Carvalho Chehab , Mike Isely References: Cc: LKML , kernel-janitors@vger.kernel.org From: SF Markus Elfring Message-ID: Date: Thu, 22 Dec 2016 20:58:51 +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: X-Provags-ID: V03:K0:V76CZFTog9BHWmQGG2kfdwSCXhsjDnkm66KgNA9agHVIpy6v6sq UUF3YO0GAM+S7Y1JeJ1kL76xzHNhLovxiP27+npuN9NQBS6PXz7zCZmwVU4XG5eHOfhAQT4 fKLBNzkNTxzbbaQ29qILUS8IhE5If1SvSY2nMkJ5SNY0BjcqphWKW5RajzEqaWAzWWsuCQI a8/v36Cm8x62iSaLmOhCg== X-UI-Out-Filterresults: notjunk:1; V01:K0:O75SYkg7gFk=:E7GzOTXvYOI/wIVP0xoCJu i6sfI4f51L1qube8ZqRwv7yuonEhZmKAhBBkaFOUzDn3ywwnyhCcAil96mRE6o5e1n3lZH8Sa +LpnDWMlKodvBtPanT04lGPByTBCBmdYVRlSP3HzhLXUNWpqJLSTNvM/x0x7Zf2XwBxXkPVAJ i9aThPVCps9MUpvW/P30IYSSKv+NfdvzbazSNwbFxj1Z4200whSWALYWt4D1wl85Kj+l0baR3 nsuYnIwFt1lHVeyTz3jIj6GUYvgN29BY6y69IL/ET0vqTU0kYiTQ27x6HnwmIGjignmwA3ePP 3/t/OgNz0vtdBfhzZD/zkwuvWjqQ2tm1JpokJGp3ERmWgIOBy/FJXO775InbdNTkZe5QWJo3f rui7Jyrf++w7lgIDoqoOOqt05J1rIFHbuS+Enzrmw7E7LTMwTAPuLYlm8rxQqPvHIeR/PAJxN LOMJXncxB3kXuQShAMmJRdg8qQGT7h/iIQ5pB5i/bx9m10BR7RqH7KXzx4Jl0b3sRc6tTRZpP KA4lyn3DfPxVAGFT75pwfzNvGatSJS1ZzWI1OtSXelPkSIHnxU1YOHp+G41+l0D1cNgEqjPQy 6Ju5P/xTSYzxYt4pOK9ydrQ24gd6fISbouZLfyxm8dEGHgtnlVqDFDsy0ZNW18ul5nA8pm8RR l8Zghrt1DhObvLagvfNS0NMfWq2xgHrLp3D9AugLImDOxwa7fjs0cdqMawdXSJpqXRwsL5P/w 6OYxHMMtR0AyRUMi0YB0U6xIQs37aKV95Vl+3OaemKe0ooRVbkVd7Qz1A7FgrZMpOXQXU8C/1 jzEixSn 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: Thu, 22 Dec 2016 19:26:52 +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. Signed-off-by: Markus Elfring --- drivers/media/usb/pvrusb2/pvrusb2-io.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/media/usb/pvrusb2/pvrusb2-io.c b/drivers/media/usb/pvrusb2/pvrusb2-io.c index e3103ecd4828..a01510bfc84f 100644 --- a/drivers/media/usb/pvrusb2/pvrusb2-io.c +++ b/drivers/media/usb/pvrusb2/pvrusb2-io.c @@ -312,7 +312,8 @@ static int pvr2_stream_buffer_count(struct pvr2_stream *sp,unsigned int cnt) if (cnt > sp->buffer_total_count) { if (scnt > sp->buffer_slot_count) { struct pvr2_buffer **nb; - nb = kmalloc(scnt * sizeof(*nb),GFP_KERNEL); + + nb = kmalloc_array(scnt, sizeof(*nb), GFP_KERNEL); if (!nb) return -ENOMEM; if (sp->buffer_slot_count) { memcpy(nb,sp->buffers,