Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp2481532ybt; Sun, 21 Jun 2020 22:26:31 -0700 (PDT) X-Google-Smtp-Source: ABdhPJznjbitpBoc2jd7lvkM7G6h/R+NkKa+4IxR6ZXq/Lqymb9A43w1a7vyBSGoFrq9YFtRnZbj X-Received: by 2002:a05:6402:b37:: with SMTP id bo23mr15554407edb.24.1592803590932; Sun, 21 Jun 2020 22:26:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1592803590; cv=none; d=google.com; s=arc-20160816; b=NgDZ1owdsR7Ne0cEUZdKQFIGebskzTpKx5fdY4pRHY8dKzNUcLZ/gUb4uNYTQAr9wR nT07RGorHAoUlRQ0kKWo7/x4YrIQx3f7EtF879obDo4gb2tNLFAyMYe3b24Gwc+hif2k Jh7QQTrD+iIuowinD42i8K2qG81k5OziggLeZXRCxiieGKu2GtqazLo2hsNhyistqxov KIyLuF1ft2PcMWO1z6P3ugoLCba39/S3378DLfk0l+jxYInK/G02LaPneFX3RAoJi3Of nacDcXO7Hb9wYBJvyxMUp4TkucUi5kaIoMXDIkms/FHi1qrhXpq9aStm7DTGrVceK8Ck VRjw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:in-reply-to :mime-version:user-agent:date:message-id:from:cc:references:to :subject; bh=m3xPMxfJkmKwpZzFhWDwEp1iOodzk/KLFHqJYm8scYY=; b=x9nPNxiD+vEPjuuE5h4XG8w/9BsQizdhT49VM29J+gZyPB7B/4zVloGzSviQv/HNkP YRQFlVP/HM6yDeGO9yQ7tOGCCsH6GcqrwjB0/L1TrVI6O3aOQFhqUFuw5X9UhdKGi2D0 cpxOyT3pzzy5ii+3htSO2tWQqgO7o2lHqVsvOqiUY09TKbjDuFW8jIJ2f6f6FW19fp1w HpJfVSTFkzPJ9K1akd+DN30JenP/mVxKRjGKSuZmnDzeOt7YfEg1J9YkyUyA26McMF8z m3PcIz2xbqlzrZ+JKHjWGKB1p+E2PnuJtXVVo20z0+X1XsTmg3bFcve0XgCNRGVT97m+ WxmQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id w4si8532406ejj.300.2020.06.21.22.26.07; Sun, 21 Jun 2020 22:26:30 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729021AbgFVFYV (ORCPT + 99 others); Mon, 22 Jun 2020 01:24:21 -0400 Received: from szxga04-in.huawei.com ([45.249.212.190]:6380 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1725934AbgFVFYU (ORCPT ); Mon, 22 Jun 2020 01:24:20 -0400 Received: from DGGEMS403-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id 9F0D935380A6FDC61A87; Mon, 22 Jun 2020 13:24:16 +0800 (CST) Received: from [10.63.139.185] (10.63.139.185) by DGGEMS403-HUB.china.huawei.com (10.3.19.203) with Microsoft SMTP Server id 14.3.487.0; Mon, 22 Jun 2020 13:24:13 +0800 Subject: Re: [PATCH][next] dmaengine: hisilicon: Use struct_size() in devm_kzalloc() To: "Gustavo A. R. Silva" , Dan Williams , Vinod Koul References: <20200617211135.GA8660@embeddedor> CC: , , "Gustavo A. R. Silva" From: Zhou Wang Message-ID: <5EF0407D.2050007@hisilicon.com> Date: Mon, 22 Jun 2020 13:24:13 +0800 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.5.1 MIME-Version: 1.0 In-Reply-To: <20200617211135.GA8660@embeddedor> Content-Type: text/plain; charset="windows-1252" Content-Transfer-Encoding: 7bit X-Originating-IP: [10.63.139.185] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2020/6/18 5:11, Gustavo A. R. Silva wrote: > Make use of the struct_size() helper instead of an open-coded version > in order to avoid any potential type mistakes. > > This code was detected with the help of Coccinelle and, audited and > fixed manually. > > Signed-off-by: Gustavo A. R. Silva Looks good to me, thanks! Reviewed-by: Zhou Wang > --- > drivers/dma/hisi_dma.c | 5 +---- > 1 file changed, 1 insertion(+), 4 deletions(-) > > diff --git a/drivers/dma/hisi_dma.c b/drivers/dma/hisi_dma.c > index ed3619266a48..e1a958ae7925 100644 > --- a/drivers/dma/hisi_dma.c > +++ b/drivers/dma/hisi_dma.c > @@ -511,7 +511,6 @@ static int hisi_dma_probe(struct pci_dev *pdev, const struct pci_device_id *id) > struct device *dev = &pdev->dev; > struct hisi_dma_dev *hdma_dev; > struct dma_device *dma_dev; > - size_t dev_size; > int ret; > > ret = pcim_enable_device(pdev); > @@ -534,9 +533,7 @@ static int hisi_dma_probe(struct pci_dev *pdev, const struct pci_device_id *id) > if (ret) > return ret; > > - dev_size = sizeof(struct hisi_dma_chan) * HISI_DMA_CHAN_NUM + > - sizeof(*hdma_dev); > - hdma_dev = devm_kzalloc(dev, dev_size, GFP_KERNEL); > + hdma_dev = devm_kzalloc(dev, struct_size(hdma_dev, chan, HISI_DMA_CHAN_NUM), GFP_KERNEL); > if (!hdma_dev) > return -EINVAL; > >