public inbox for dmaengine@vger.kernel.org
 help / color / mirror / Atom feed
From: Vinod Koul <vkoul@kernel.org>
To: Yu Liao <liaoyu15@huawei.com>
Cc: liwei391@huawei.com, dmaengine@vger.kernel.org
Subject: Re: [PATCH -next 2/2] dmaengine: mcf-edma: use struct_size() helper
Date: Mon, 21 Aug 2023 11:18:26 +0530	[thread overview]
Message-ID: <ZOL6qokJlH/W5RNo@matsya> (raw)
In-Reply-To: <20230816020355.3002617-2-liaoyu15@huawei.com>

On 16-08-23, 10:03, Yu Liao wrote:
> Make use of the struct_size() helper instead of an open-coded version,
> in order to avoid any potential type mistakes or integer overflows that,
> in the worst scenario, could lead to heap overflows.

Duplicate to 923b13838892 ("dmaengine: mcf-edma: Use struct_size()")

> 
> Signed-off-by: Yu Liao <liaoyu15@huawei.com>
> ---
>  drivers/dma/mcf-edma.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/drivers/dma/mcf-edma.c b/drivers/dma/mcf-edma.c
> index 9413fad08a60..444b5c1bd7dc 100644
> --- a/drivers/dma/mcf-edma.c
> +++ b/drivers/dma/mcf-edma.c
> @@ -180,7 +180,6 @@ static int mcf_edma_probe(struct platform_device *pdev)
>  {
>  	struct mcf_edma_platform_data *pdata;
>  	struct fsl_edma_engine *mcf_edma;
> -	struct fsl_edma_chan *mcf_chan;
>  	struct edma_regs *regs;
>  	int ret, i, len, chans;
>  
> @@ -197,7 +196,7 @@ static int mcf_edma_probe(struct platform_device *pdev)
>  		chans = pdata->dma_channels;
>  	}
>  
> -	len = sizeof(*mcf_edma) + sizeof(*mcf_chan) * chans;
> +	len = struct_size(mcf_edma, chans, chans);
>  	mcf_edma = devm_kzalloc(&pdev->dev, len, GFP_KERNEL);
>  	if (!mcf_edma)
>  		return -ENOMEM;
> -- 
> 2.25.1

-- 
~Vinod

  reply	other threads:[~2023-08-21  5:48 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-08-16  2:03 [PATCH -next 1/2] dmaengine: fsl-edma: use struct_size() helper Yu Liao
2023-08-16  2:03 ` [PATCH -next 2/2] dmaengine: mcf-edma: " Yu Liao
2023-08-21  5:48   ` Vinod Koul [this message]
2023-08-21  5:47 ` [PATCH -next 1/2] dmaengine: fsl-edma: " Vinod Koul
2023-08-21  6:06   ` Yu Liao

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ZOL6qokJlH/W5RNo@matsya \
    --to=vkoul@kernel.org \
    --cc=dmaengine@vger.kernel.org \
    --cc=liaoyu15@huawei.com \
    --cc=liwei391@huawei.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox