[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <aEfm5ia_i4DrKnt6@stanley.mountain>
Date: Tue, 10 Jun 2025 11:03:50 +0300
From: Dan Carpenter <dan.carpenter@...aro.org>
To: "Rangoju, Raju" <raju.rangoju@....com>
Cc: broonie@...nel.org, linux-spi@...r.kernel.org,
linux-kernel@...r.kernel.org, miquel.raynal@...tlin.com,
Krishnamoorthi M <krishnamoorthi.m@....com>,
Akshata MukundShetty <akshata.mukundshetty@....com>, cve@...nel.org,
Harshit Mogalapalli <harshit.m.mogalapalli@...cle.com>
Subject: Re: [PATCH] spi: spi-mem: Add fix to avoid divide error
On Mon, Jun 09, 2025 at 04:10:53PM +0530, Rangoju, Raju wrote:
>
>
> On 6/2/2025 3:15 PM, Dan Carpenter wrote:
> > On Thu, Apr 24, 2025 at 05:43:33PM +0530, Raju Rangoju wrote:
> > >
> > > Fixes: 226d6cb3cb79 ("spi: spi-mem: Estimate the time taken by operations")
> > > Suggested-by: Krishnamoorthi M <krishnamoorthi.m@....com>
> > > Co-developed-by: Akshata MukundShetty <akshata.mukundshetty@....com>
> > > Signed-off-by: Akshata MukundShetty <akshata.mukundshetty@....com>
> > > Signed-off-by: Raju Rangoju <Raju.Rangoju@....com>
> > > ---
> > > drivers/spi/spi-mem.c | 6 +++++-
> > > 1 file changed, 5 insertions(+), 1 deletion(-)
> > >
> > > diff --git a/drivers/spi/spi-mem.c b/drivers/spi/spi-mem.c
> > > index a31a1db07aa4..5db0639d3b01 100644
> > > --- a/drivers/spi/spi-mem.c
> > > +++ b/drivers/spi/spi-mem.c
> > > @@ -596,7 +596,11 @@ u64 spi_mem_calc_op_duration(struct spi_mem_op *op)
> > > ns_per_cycles = 1000000000 / op->max_freq;
> > > ncycles += ((op->cmd.nbytes * 8) / op->cmd.buswidth) / (op->cmd.dtr ? 2 : 1);
> > > ncycles += ((op->addr.nbytes * 8) / op->addr.buswidth) / (op->addr.dtr ? 2 : 1);
> > > - ncycles += ((op->dummy.nbytes * 8) / op->dummy.buswidth) / (op->dummy.dtr ? 2 : 1);
> > > +
> > > + /* Dummy bytes are optional for some SPI flash memory operations */
> > > + if (op->dummy.nbytes)
> > > + ncycles += ((op->dummy.nbytes * 8) / op->dummy.buswidth) / (op->dummy.dtr ? 2 : 1);
> > > +
> >
> > Hi,
> >
> > We were reviewing "CVE-2025-37896: spi: spi-mem: Add fix to avoid divide
> > error" which was issued for this patch, but this patch is a no-op.
> >
> > If op->dummy.nbytes is zero then the original code does:
> >
> > ncycles += 0;
> >
> > We don't divide by op->dummy.nbytes. Was something else intended?
>
> Hi,
>
> When there are no dummy bytes for an spi-mem operation, both
> op->dummy.nbytes and op->dummy.buswidth are zero.
>
> This can lead to a divide-by-zero error.
>
Ah. Ok. I didn't realize they were connected that way. Thanks!
regards,
dan carpenter
Powered by blists - more mailing lists