From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932687AbcH2Jru (ORCPT ); Mon, 29 Aug 2016 05:47:50 -0400 Received: from mx1.redhat.com ([209.132.183.28]:53130 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756558AbcH2Jrt (ORCPT ); Mon, 29 Aug 2016 05:47:49 -0400 Subject: Re: [PATCH 1/2] sparc: Use kmalloc_array() in three functions To: SF Markus Elfring , sparclinux@vger.kernel.org, "David S. Miller" References: <0ca0235c-ddb9-0534-3bde-b4aaa48da92e@users.sourceforge.net> Cc: LKML , kernel-janitors@vger.kernel.org, Julia Lawall From: Paolo Bonzini Message-ID: <4475e65d-415d-9cde-1fe1-c17e120849c4@redhat.com> Date: Mon, 29 Aug 2016 11:47:38 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.2.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Mon, 29 Aug 2016 09:47:42 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 25/08/2016 10:22, SF Markus Elfring wrote: > --- a/arch/sparc/kernel/led.c > +++ b/arch/sparc/kernel/led.c > @@ -69,7 +69,7 @@ static ssize_t led_proc_write(struct file *file, const char __user *buffer, > if (count > LED_MAX_LENGTH) > count = LED_MAX_LENGTH; > > - buf = kmalloc(sizeof(char) * (count + 1), GFP_KERNEL); > + buf = kmalloc_array(count + 1, sizeof(*buf), GFP_KERNEL); > if (!buf) > return -ENOMEM; > Here it's probably best to just remove sizeof(char) completely, as it's 1 by definition. Paolo From mboxrd@z Thu Jan 1 00:00:00 1970 From: Paolo Bonzini Date: Mon, 29 Aug 2016 09:47:38 +0000 Subject: Re: [PATCH 1/2] sparc: Use kmalloc_array() in three functions Message-Id: <4475e65d-415d-9cde-1fe1-c17e120849c4@redhat.com> List-Id: References: <0ca0235c-ddb9-0534-3bde-b4aaa48da92e@users.sourceforge.net> In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: SF Markus Elfring , sparclinux@vger.kernel.org, "David S. Miller" Cc: LKML , kernel-janitors@vger.kernel.org, Julia Lawall On 25/08/2016 10:22, SF Markus Elfring wrote: > --- a/arch/sparc/kernel/led.c > +++ b/arch/sparc/kernel/led.c > @@ -69,7 +69,7 @@ static ssize_t led_proc_write(struct file *file, const char __user *buffer, > if (count > LED_MAX_LENGTH) > count = LED_MAX_LENGTH; > > - buf = kmalloc(sizeof(char) * (count + 1), GFP_KERNEL); > + buf = kmalloc_array(count + 1, sizeof(*buf), GFP_KERNEL); > if (!buf) > return -ENOMEM; > Here it's probably best to just remove sizeof(char) completely, as it's 1 by definition. Paolo