From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S965304AbcIXRyU (ORCPT ); Sat, 24 Sep 2016 13:54:20 -0400 Received: from mail-ua0-f175.google.com ([209.85.217.175]:35228 "EHLO mail-ua0-f175.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932768AbcIXRyR (ORCPT ); Sat, 24 Sep 2016 13:54:17 -0400 MIME-Version: 1.0 In-Reply-To: <2a1f52e8-a502-1d4b-d9c9-e806cc6f246e@users.sourceforge.net> References: <566ABCD9.1060404@users.sourceforge.net> <92cc52f5-c5e1-cafe-76f2-04e4ed997735@users.sourceforge.net> <2a1f52e8-a502-1d4b-d9c9-e806cc6f246e@users.sourceforge.net> From: Dmitry Torokhov Date: Sat, 24 Sep 2016 10:54:15 -0700 Message-ID: Subject: Re: [PATCH 1/2] Input-evdev: Use kmalloc_array() in evdev_handle_get_val() To: SF Markus Elfring Cc: "linux-input@vger.kernel.org" , Henrik Rydberg , LKML , kernel-janitors@vger.kernel.org, Julia Lawall Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, Sep 24, 2016 at 4:08 AM, SF Markus Elfring wrote: > From: Markus Elfring > Date: Sat, 24 Sep 2016 12:42:45 +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 type by a pointer dereference > to make the corresponding size determination a bit safer according to > the Linux coding style convention. > > * Delete the local variable "len" which became unnecessary with > this refactoring. So we have to multiply twice now, once in kmalloc_array, the second time in memcpy(). No, thank you. Also, please note that we do not really treat the allocated "mem" as an array, but rather area of memory that holds all bits that we need to transfer, and so I consider using kmalloc_array() actually wrong here. Please do not blindly follow checkpatch and coccinelle suggestions. They are just that: suggestions and not hared rules. Thanks. -- Dmitry