From patchwork Sun Dec 25 18:29:46 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: 9488267 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 5E1AC60471 for ; Sun, 25 Dec 2016 18:30:14 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5159D205AD for ; Sun, 25 Dec 2016 18:30:14 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 45E2825D97; Sun, 25 Dec 2016 18:30:14 +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 01928205AD for ; Sun, 25 Dec 2016 18:30:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932179AbcLYS35 (ORCPT ); Sun, 25 Dec 2016 13:29:57 -0500 Received: from mout.web.de ([212.227.15.3]:49344 "EHLO mout.web.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750797AbcLYS3z (ORCPT ); Sun, 25 Dec 2016 13:29:55 -0500 Received: from [192.168.1.2] ([77.182.80.223]) by smtp.web.de (mrweb003 [213.165.67.108]) with ESMTPSA (Nemesis) id 0M4qcP-1ckzjN2l93-00yzB4; Sun, 25 Dec 2016 19:29:48 +0100 Subject: [PATCH 01/19] [media] uvc_driver: Use kmalloc_array() in uvc_simplify_fraction() 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: <67e337ba-f2e0-48ac-f6b9-e7e392eb92d7@users.sourceforge.net> Date: Sun, 25 Dec 2016 19:29:46 +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:YdUxQNUMJRQmTcGL1l+TltUKfJc/WMstcNMX5k3Knc6UVlRNmSo /IZDTI0A0Z0PTyOunJby1nFh2+Q84s0shLDM31nbHo3A7aYx92oCu1nLNuZPO8T5OG3NzoF F3/86JP7qKizYGmYHLLrMo2YzzCLek0J/W/wf2+XuAVcJ+OWp1XMoKhh6DHOPfakftCX9i5 MWs/GgAg1C/evDEeh5mdA== X-UI-Out-Filterresults: notjunk:1; V01:K0:OeJ56si0Tzw=:42hFJScp+ExGrIoeYhS3xS /YKiPn5wtA+WJ+9I2GZYCXyWhe2ILNr3w/jyGbZfL4jKpRmBR873TQexoVUT6cx8PuOhKX/4M LOYVLlS9ndz/IXKg7LcYLyGImFjve4Z/Pd7FPkuanN+KvzDBSp03/BIQF0ewZhLSwd+EJRWNk B6L1jeNVVNa4Vs3RyvH4EhQRLqCVBIEvXqgoLak5qWCmSuMM8ghjSoLH6+Hd4hv2W/OdCFTbC BWMybqUOgtXIWezWYHQiW18xWea74393FNU2UtZ7ErcMO9vIau4wzSNYi06wokhU4V7tUM9Zp h2++KvW01Ts77FDSyI9/NhwBuAMGC990+HBH3tJ9xjUyNGt8Y/yVbY5GklJPjbfkq7mmzYdW6 +jnHDy4uveKPbGhtTtf+NhhNQ+4eWMJnJCyhF4eeVCjHJ/63VyJJhjiZY1yEab50rxGdeZMQK sUKhvOgUKn7lIMnlbIS9xtjIBsEndr34SYWTjwqRHnosoKELlmIdvDt53hP8XlEynNGxKroCx q4jtvezMIVHzRItCz/nFUfWaDbAY/3lvLLKjLXhXiocfa87buIhoTz72QfXPv2p4crI7zcUlq hPU6d8/udAtHB0qq9rA86EZOVgTeMJrzqhs0utuGUyuypZtpW2H49Bju2bgL5wof9QLLHTuXJ ZmdLgK/fS194xKZG2EbCnPbI1s6klRibIehR7GYFKnWLMBivZ5h9FQGYFpiH29AerAnuIUwWQ s2wyg67AXPZwijuE/Lq3sSEeCInGDcqn1c6Ob1FWtrK4CBD9zVmotUws//sAALXjMgKxkepXj 7RMINo+ 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: Sat, 24 Dec 2016 21:10:16 +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_driver.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/media/usb/uvc/uvc_driver.c b/drivers/media/usb/uvc/uvc_driver.c index 04bf35063c4c..a64b5029f262 100644 --- a/drivers/media/usb/uvc/uvc_driver.c +++ b/drivers/media/usb/uvc/uvc_driver.c @@ -253,7 +253,7 @@ void uvc_simplify_fraction(uint32_t *numerator, uint32_t *denominator, uint32_t x, y, r; unsigned int i, n; - an = kmalloc(n_terms * sizeof *an, GFP_KERNEL); + an = kmalloc_array(n_terms, sizeof(*an), GFP_KERNEL); if (an == NULL) return;