Re: [PATCH v6] dma-buf: Fix silent overflow for phys vec to sgt

From: David Hu

Date: Tue Jun 09 2026 - 12:33:57 EST


On Tue, Jun 9, 2026 at 3:22 AM Leon Romanovsky <leon@xxxxxxxxxx> wrote:
>
> On Mon, Jun 08, 2026 at 07:43:21PM +0000, David Hu wrote:
> > diff --git a/drivers/dma-buf/dma-buf-mapping.c b/drivers/dma-buf/dma-buf-mapping.c
> > index 794acff2546a..67a8ff52fb8f 100644
> > --- a/drivers/dma-buf/dma-buf-mapping.c
> > +++ b/drivers/dma-buf/dma-buf-mapping.c
> > @@ -40,8 +41,11 @@ static unsigned int calc_sg_nents(struct dma_iova_state *state,
> > size_t i;
> >
> > if (!state || !dma_use_iova(state)) {
> > - for (i = 0; i < nr_ranges; i++)
> > - nents += DIV_ROUND_UP(phys_vec[i].len, UINT_MAX);
> > + for (i = 0; i < nr_ranges; i++) {
> > + unsigned int added = DIV_ROUND_UP(phys_vec[i].len, UINT_MAX);
> > + if (check_add_overflow(nents, added, &nents))
>
> An additional blank line should be inserted between variable initialization
> and the subsequent code block.
>
> Aside from that,
> Reviewed-by: Leon Romanovsky <leon@xxxxxxxxxx>

Thank you, Leon, for the review and for catching the formatting
detail. I'll add a blank line, include your Reviewed-by tag, and send
out v7 shortly.

Regards,
David