From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751240AbeAVPrk (ORCPT ); Mon, 22 Jan 2018 10:47:40 -0500 Received: from mail-wr0-f195.google.com ([209.85.128.195]:41894 "EHLO mail-wr0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751147AbeAVPrh (ORCPT ); Mon, 22 Jan 2018 10:47:37 -0500 X-Google-Smtp-Source: AH8x224cvQU9JC+QZ4MrowVNNwwziyYnA/Akx2G1nsBu5vltmQw6CQFIWS5gX/fBCQwCUoF2arCK2Q== Date: Mon, 22 Jan 2018 15:47:33 +0000 From: Lee Jones To: SF Markus Elfring Cc: kernel-janitors@vger.kernel.org, LKML Subject: Re: [PATCH 2/3] mfd/sm501: Improve a size determination in two functions Message-ID: <20180122154733.zpqfqryoyrwo63s2@dell> References: <3b264527-b43f-b6aa-0570-c6d48ed24679@users.sourceforge.net> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <3b264527-b43f-b6aa-0570-c6d48ed24679@users.sourceforge.net> User-Agent: NeoMutt/20170113 (1.7.2) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 15 Jan 2018, SF Markus Elfring wrote: > From: Markus Elfring > Date: Mon, 15 Jan 2018 15:47:03 +0100 > > Replace the specification of data structures by pointer dereferences > as the parameter for the operator "sizeof" to make the corresponding size > determination a bit safer according to the Linux coding style convention. > > This issue was detected by using the Coccinelle software. > > Signed-off-by: Markus Elfring > --- > drivers/mfd/sm501.c | 6 ++---- > 1 file changed, 2 insertions(+), 4 deletions(-) > > diff --git a/drivers/mfd/sm501.c b/drivers/mfd/sm501.c > index 7298d6b571a1..d5ab3481794a 100644 > --- a/drivers/mfd/sm501.c > +++ b/drivers/mfd/sm501.c > @@ -1380,10 +1380,9 @@ static int sm501_init_dev(struct sm501_devdata *sm) > > static int sm501_plat_probe(struct platform_device *dev) > { > - struct sm501_devdata *sm; > int ret; > + struct sm501_devdata *sm = kzalloc(sizeof(*sm), GFP_KERNEL); > > - sm = kzalloc(sizeof(struct sm501_devdata), GFP_KERNEL); Leave this here please. Just s/struct sm501_devdata/*sm/ > if (sm == NULL) { > ret = -ENOMEM; > goto err1; > @@ -1569,10 +1568,9 @@ static struct sm501_platdata sm501_pci_platdata = { > static int sm501_pci_probe(struct pci_dev *dev, > const struct pci_device_id *id) > { > - struct sm501_devdata *sm; > int err; > + struct sm501_devdata *sm = kzalloc(sizeof(*sm), GFP_KERNEL); > > - sm = kzalloc(sizeof(struct sm501_devdata), GFP_KERNEL); As above. > if (sm == NULL) { > err = -ENOMEM; > goto err1; -- Lee Jones Linaro Services Technical Lead Linaro.org │ Open source software for ARM SoCs Follow Linaro: Facebook | Twitter | Blog