From patchwork Sun Dec 25 18:45:29 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: 9488315 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 960BE601D7 for ; Sun, 25 Dec 2016 18:45:58 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 91C86205B0 for ; Sun, 25 Dec 2016 18:45:58 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8668525250; Sun, 25 Dec 2016 18:45:58 +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 45DCB205B0 for ; Sun, 25 Dec 2016 18:45:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932356AbcLYSpi (ORCPT ); Sun, 25 Dec 2016 13:45:38 -0500 Received: from mout.web.de ([217.72.192.78]:62510 "EHLO mout.web.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932088AbcLYSph (ORCPT ); Sun, 25 Dec 2016 13:45:37 -0500 Received: from [192.168.1.2] ([77.182.80.223]) by smtp.web.de (mrweb103 [213.165.67.124]) with ESMTPSA (Nemesis) id 0M7KR8-1cj3oT0Tp8-00x3qX; Sun, 25 Dec 2016 19:45:31 +0100 Subject: [PATCH 13/19] [media] uvc_video: Use kmalloc_array() in uvc_video_clock_init() To: linux-media@vger.kernel.org, Laurent Pinchart , Mauro Carvalho Chehab References: <47aa4314-74ec-b2bf-ee3b-aad4d6e9f0a2@users.sourceforge.net> Cc: LKML , kernel-janitors@vger.kernel.org From: SF Markus Elfring Message-ID: <47b935d9-e063-503a-47e5-2aee2ffe149c@users.sourceforge.net> Date: Sun, 25 Dec 2016 19:45:29 +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: <47aa4314-74ec-b2bf-ee3b-aad4d6e9f0a2@users.sourceforge.net> X-Provags-ID: V03:K0:Vx3CH8mMWYnpPSRy4m1EEOSpr0rg3NbWjY+0YKUzQlFGWfVZOYB Tyb3r0m97hjgl8CKIRN4jpkNn8jKQipwLjd7nJjhiR9w/YtzrKghsWnYaOrrVk2lXtFsd1h NrPuCkUgYQKaA7uvIxQ8OvvpDfs9k+we1dPHZcjp6GkFowwWzBHUh70oooEqt1X/qOnDWRV yuDp5qOh5wjD25nU4Umjg== X-UI-Out-Filterresults: notjunk:1; V01:K0:q00T/WV8f8M=:7hOszK/pu/tpvDM0j0vkkk M78kHUlo3HSoQj3edMuF6CuVpwvXynI2Dox7nDA8AqW8fHyUnmhKkXpDIdSqferq2ZfgtlW8b WqqmcDaTxghkLq69ImH48fgLyCcp5NjMyzVwXfcra4y3neLr0GtEjpncHG6bp/3VHrJZ6Jyfd HyjXYX92ljZDR9o7UDhRmo27dNpvmbr2Uu+axH6JebhfZ3kmP8Ek89NnnnV0B92dZLgH88X/C foEIrTGvoTUoQv4E1uBPYaH2AGKWJoY8miMhnsykCAGjtQlKsYMk3J4DbR0Ldt0rVb4nr5NaB 3AMOPaoJK8vvVutMA0pe0kkX/vj5/AzbetQHuCgu8haFa117E4az2SXYvld2Wrh2b83mJIfEu pHF984jwzlfjw7fHNJtdNVz7/dJxnkj8a1gIcyl+bd6HUGHE7Qq+YFb/2cWc7Nd4+2a+oDvzm 4D6Zu0003ZTZeuUATrafY3WSsI1ffRXtGidEkkYrbuo7Cw3UIZ6HR9rK67YFjTWtFBY3SbxgY vk+Kyq3DawV6SiM9KlPWbo8uhq0I0NI9bL0OxqcYZ7juveXQ6jp9EQBP+fC9kkNVzJk885rlm RqUd1zAEIEY2HpLNfnocQl7vIUZNH8gaTv+DkEMLUFKShTwQfDuJYheD00ouYgequ8c/Z/c3N u9jOMsuqjL3npvxqhyfLZLVEoRnEWfb3dLn0yHRx7m25K+euccAnO+Cww5OtXLlbpsC5fV+Fe WgGp9OPGRaj5wbO8hQwolGWrejciyaX6oGWpfFthLSJvf0iee9onOrgtmWf4WL3ifjW4XmMzF 6T7B7Fd 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: Sun, 25 Dec 2016 16:45:21 +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/uvc/uvc_video.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/media/usb/uvc/uvc_video.c b/drivers/media/usb/uvc/uvc_video.c index f3c1c852e401..05b396f033ca 100644 --- a/drivers/media/usb/uvc/uvc_video.c +++ b/drivers/media/usb/uvc/uvc_video.c @@ -500,9 +500,9 @@ static int uvc_video_clock_init(struct uvc_streaming *stream) spin_lock_init(&clock->lock); clock->size = 32; - - clock->samples = kmalloc(clock->size * sizeof(*clock->samples), - GFP_KERNEL); + clock->samples = kmalloc_array(clock->size, + sizeof(*clock->samples), + GFP_KERNEL); if (clock->samples == NULL) return -ENOMEM;