From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754619AbcH2Qrc (ORCPT ); Mon, 29 Aug 2016 12:47:32 -0400 Received: from mx1.redhat.com ([209.132.183.28]:46930 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751008AbcH2Qra (ORCPT ); Mon, 29 Aug 2016 12:47:30 -0400 Subject: Re: [PATCH 1/2] sparc: Use kmalloc_array() in three functions To: wharms@bfs.de References: <0ca0235c-ddb9-0534-3bde-b4aaa48da92e@users.sourceforge.net> <4475e65d-415d-9cde-1fe1-c17e120849c4@redhat.com> <57C42335.5000106@bfs.de> Cc: SF Markus Elfring , sparclinux@vger.kernel.org, "David S. Miller" , LKML , kernel-janitors@vger.kernel.org, Julia Lawall From: Paolo Bonzini Message-ID: Date: Mon, 29 Aug 2016 18:38:53 +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: <57C42335.5000106@bfs.de> 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.27]); Mon, 29 Aug 2016 16:38:58 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 29/08/2016 13:57, walter harms wrote: > > > - 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. > > I would not do so, if you ever change buf to something else it would break, > having a sizeof(*buf) here is harmless and a known pattern. Fair enough, it's not code I maintain. Paolo