From patchwork Sat Sep 24 13:46:21 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: 9349173 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 A4D63607F0 for ; Sat, 24 Sep 2016 13:46:43 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9647328F3A for ; Sat, 24 Sep 2016 13:46:43 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8B15F291A4; Sat, 24 Sep 2016 13:46:43 +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 3928D28F3A for ; Sat, 24 Sep 2016 13:46:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758319AbcIXNq1 (ORCPT ); Sat, 24 Sep 2016 09:46:27 -0400 Received: from mout.web.de ([212.227.15.4]:60874 "EHLO mout.web.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1758297AbcIXNq0 (ORCPT ); Sat, 24 Sep 2016 09:46:26 -0400 Received: from [192.168.1.2] ([78.53.181.42]) by smtp.web.de (mrweb001) with ESMTPSA (Nemesis) id 0MUVvf-1bNDjy3OwF-00RI8e; Sat, 24 Sep 2016 15:46:21 +0200 Subject: [PATCH 1/4] Input-gameport: Use kmalloc_array() in joydump_connect() To: linux-input@vger.kernel.org, Dmitry Torokhov References: Cc: LKML , kernel-janitors@vger.kernel.org, Julia Lawall From: SF Markus Elfring Message-ID: <7ff91d13-9111-c75a-1c1a-e119025866e7@users.sourceforge.net> Date: Sat, 24 Sep 2016 15:46:21 +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: X-Provags-ID: V03:K0:CoBCtAbeE6RXfhVoaenAqYVkOtlUDWti09qYo9s6QUvRaeFq/5r 7n5Hyc7JnMp1uq1FjIt7sD+VfxMxmhlgwNlibsxcyg5sVSRAcDiCpg3Smd+no5USD3Besd5 D2srHh8NWeW+La7R1A3ahp1cXEgszJZpO4xM2nvd6GJ9aoyFWeMgAPMceKk1kHDbTJncPMO dm/cmDI7yY6JQb1YaPbcw== X-UI-Out-Filterresults: notjunk:1; V01:K0:U9MtbokQhX8=:r6V97/AS+qzQ3OxU6KZzzG GifM5eW/CCthwMOzRfRGxs761Ll990eCAxUqCYZrd+VDnRVurJzmbF/fbB53wKLsTpNdtkKJ0 vAA9/exfXXntD/x4TIYh006/AF+86l5MAA8au7ABa+OUmkCU8vx/hd2+tLtEsGE3+REX0ec86 SidIxHS50s2xGyqlwbUeeRFhwa78PHNA1VgWAZJgJ1zuQQiPBEe1Ob92PIx8DV+x5WiXclbdw 1o778SsU+W2rtymdHANmlp8uRWzdz6AylY9bV9918+4MjaMS6ObXXBNd5YNYcIvfMcEzZ7OD3 bhthNxi/iB72M0hsBVE9p/iByS0wNcUu2yhnwbaVAkRPgbAGkVYzoHgH/1x1yP+lc12fYiTzD d8oCoJjm99Zx9LPV3sg+HTDILRmcdbkshXvpX7fz1nWwol6KG4i9nqupd6GEAYWTtc11w9jmP YmyyjNvuC+ROBheEcE51PCsohIe7sDZbFg20DE9f+6Q+QPXHiTinwxi1czxmJIm8FeVbHe2mJ FZrf4FxtUkmlHIcO5vxdl1RcJmM2u8sP5fxY6yYuL3zOoSqnGFY8EH1Ga4X/r5gtFUsb9GFkV Big67x/Ys5TBzF9Wgjxpen3TxPnlzn1//3/IRUUPZlYnITVuw9dqNpefcODukTOTWZ9CLdE/B jX5Q1Ss6uCb1p+GCayCsy7RX0ENrbMfHm3Sq43bV/W7eYKNzlBeB7VvTSV7DH2wPbP6nKJSMA cxx0B8QkTdhSFs2LqrghmhoYcX0W3ySAnGCTnK01pRhtF0DOpcS3A6APF7q5LT3AUg19r5wuK 3WgHKz2 Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Markus Elfring Date: Sat, 24 Sep 2016 13:50:20 +0200 * 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 structure 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/input/joystick/joydump.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/input/joystick/joydump.c b/drivers/input/joystick/joydump.c index d1c6e48..e515058 100644 --- a/drivers/input/joystick/joydump.c +++ b/drivers/input/joystick/joydump.c @@ -79,8 +79,7 @@ static int joydump_connect(struct gameport *gameport, struct gameport_driver *dr } timeout = gameport_time(gameport, 10000); /* 10 ms */ - - buf = kmalloc(BUF_SIZE * sizeof(struct joydump), GFP_KERNEL); + buf = kmalloc_array(BUF_SIZE, sizeof(*buf), GFP_KERNEL); if (!buf) { printk(KERN_INFO "joydump: no memory for testing\n"); goto jd_end;