From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754198AbcIJOYE (ORCPT ); Sat, 10 Sep 2016 10:24:04 -0400 Received: from mout.web.de ([212.227.17.12]:62171 "EHLO mout.web.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753229AbcIJOYC (ORCPT ); Sat, 10 Sep 2016 10:24:02 -0400 Subject: [PATCH 1/7] cfag12864b: Use kmalloc_array() in cfag12864b_init() To: kernel-janitors@vger.kernel.org, Miguel Ojeda Sandonis References: <566ABCD9.1060404@users.sourceforge.net> <3d24b514-4e99-86ea-d69e-49a0b1edd286@users.sourceforge.net> Cc: LKML , Julia Lawall From: SF Markus Elfring Message-ID: Date: Sat, 10 Sep 2016 16:23:57 +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: <3d24b514-4e99-86ea-d69e-49a0b1edd286@users.sourceforge.net> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Provags-ID: V03:K0:CTsc7Osw8gjBg1dTIq6ouG2FVw785BF7hOrfG5O0y4pwKZgKDdZ Jt5eruyTgSFBwJy3nTC9pYbNmeNv4E/lQbJKJuO+Tl6JtccLhqxhIoSuEcLXvKL4hZoOHKL KPPl22UqALFrh4gz3gziL+q4XvSIGurgUoPoJfUjvG2Zmo9Twxil+TcEYkh78gzmXpvB5t8 /wEjSJNB0/xVJbVnW7KWA== X-UI-Out-Filterresults: notjunk:1;V01:K0:w2spzE66Wr0=:ZeD4DJJLjvxhexINU7Fwzh 8EIYAWYjizWj0cBImV46SOVtg9VzDoj6ZsgYEOcxJqYf+1l9/6XBUyW+aQemuafn+0OEgH0PG uDoyBkoPOVEFlvXnR0FSq7qE1ioVmfcx/nvXd8QYar6fxxZmgVaJgHib4e9hku54HM8WwYEoR TkeC3s/6zi+evw8E/lVpit1egm+8p9qohrokaAv/AvK5LfkUFlJ5IpuCTNK/00k6lmsO8yBbe zkGhCGx6qBy+/kLhDGNw9HoJ21WE9WIbBd2LvtNvv4D+w9jPlqv8gBgf9fTPYgPrhwKWt94Ks ssW6J2KtynAhIYnJCKKu91lmVHA6YcmJIxusHO6ddeSbWt8qooPcqXboDUvLK+fp3OEZgspmr cXkNHgF3FpaZ3B5GsteobgTuMb2/VNAuNsY/5uqFhMmVnV2cXf7oP6qi2ungGBNKp1rtPhbt8 Kko/FReTHAVtc+zRnuTfEvM2ZE58X/cjZFhgFGDQ+2nYXjcg8ouaeGPHhTa7tYfEyWUSkE1m7 EnfTm2KYDUaAZSmCD03y/DBi6TL9/mO2Y3p8T86HUtTJDtU5UEw8Z59MUKMhE6em3ZisN1OBY sdbaznPQ5pvewJQ4oL/5uM6M9YupZHGsPpCtQyxFgHoHR7960j/8Y+TtiqPRDEFC4Se9k3Mfe lR/6FMoycgTsWD1UJDuC3E+lr68iYwYv6APhZZmhHN2iU+GCom8br24M+8bNJCLpvl50JBZRo 0Ek1D7gadCBaanZnDL9i5VOvKlNgNFAhaaGpXCP/U14BtKXwEO0dQvwSSgAnkj5lGAWxmfsMv h+qB/mJ Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Markus Elfring Date: Sat, 10 Sep 2016 14:40:48 +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. Signed-off-by: Markus Elfring --- drivers/auxdisplay/cfag12864b.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/auxdisplay/cfag12864b.c b/drivers/auxdisplay/cfag12864b.c index 41ce4bd..88260f4 100644 --- a/drivers/auxdisplay/cfag12864b.c +++ b/drivers/auxdisplay/cfag12864b.c @@ -347,8 +347,9 @@ static int __init cfag12864b_init(void) goto none; } - cfag12864b_cache = kmalloc(sizeof(unsigned char) * - CFAG12864B_SIZE, GFP_KERNEL); + cfag12864b_cache = kmalloc_array(CFAG12864B_SIZE, + sizeof(*cfag12864b_cache), + GFP_KERNEL); if (cfag12864b_cache == NULL) { printk(KERN_ERR CFAG12864B_NAME ": ERROR: " "can't alloc cache buffer (%i bytes)\n", -- 2.10.0