New Defects reported by Coverity Scan for Das U-Boot
I think unfortunately the report email for when I merged in -next was lost somewhere / wasn't sent. I may be able to get the details out the dashboard.
---------- Forwarded message ---------
From: <[email protected]>
Date: Fri, Oct 10, 2025 at 7:08 PM
Subject: New Defects reported by Coverity Scan for Das U-Boot
To: <[email protected]>
Hi,
Please find the latest report on new defect(s) introduced to *Das U-Boot* found with Coverity Scan.
- *New Defects Found:* 1
- *Defects Shown:* Showing 1 of 1 defect(s)
Defect Details
** CID 537478: Integer handling issues (OVERFLOW_BEFORE_WIDEN)
/drivers/spi/spi-mem.c: 528 in spi_mem_calc_op_duration()
_____________________________________________________________________________________________
*** CID 537478: Integer handling issues (OVERFLOW_BEFORE_WIDEN)
/drivers/spi/spi-mem.c: 528 in spi_mem_calc_op_duration()
522 ncycles += ((op->addr.nbytes * 8) / op->addr.buswidth) /
(op->addr.dtr ? 2 : 1);
523
524 /* Dummy bytes are optional for some SPI flash memory operations */ 525 if (op->dummy.nbytes) 526 ncycles += ((op->dummy.nbytes * 8) / op->dummy.buswidth) /
(op->dummy.dtr ? 2 : 1);
527
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
CID 537478: Integer handling issues (
OVERFLOW_BEFORE_WIDEN)
Potentially overflowing expression "op->data.nbytes* 8U" with type "unsigned int" (32 bits, unsigned) is evaluated using 32-bit arithmetic, and then used in a context that expects an expression of type "u64" (64 bits, unsigned).
528 ncycles += ((op->data.nbytes * 8) / op->data.buswidth) /
(op->data.dtr ? 2 : 1);
529
530 return ncycles; 531 } 532 EXPORT_SYMBOL_GPL(spi_mem_calc_op_duration);
533
View Defects in Coverity Scan
<https://scan.coverity.com/projects/das-u-boot?tab=overview>
Best regards,
The Coverity Scan Admin Team
----- End forwarded message -----
Signature · 1 line
Tom
Quoted 34 lines · Tom Rini
I think unfortunately the report email for when I merged in -next was lost somewhere / wasn't sent. I may be able to get the details out the dashboard.
---------- Forwarded message ---------
From: <[email protected]>
Date: Fri, Oct 10, 2025 at 7:08 PM
Subject: New Defects reported by Coverity Scan for Das U-Boot
To: <[email protected]>Hi,
Please find the latest report on new defect(s) introduced to *Das U-Boot* found with Coverity Scan.
- *New Defects Found:* 1
- *Defects Shown:* Showing 1 of 1 defect(s)Defect Details
** CID 537478: Integer handling issues (
OVERFLOW_BEFORE_WIDEN)
/drivers/spi/spi-mem.c: 528 inspi_mem_calc_op_duration()_____________________________________________________________________________________________
*** CID 537478: Integer handling issues (OVERFLOW_BEFORE_WIDEN)
/drivers/spi/spi-mem.c: 528 inspi_mem_calc_op_duration()
522 ncycles += ((op->addr.nbytes* 8) /op->addr.buswidth) /
(op->addr.dtr? 2 : 1);
523524 /* Dummy bytes are optional for some SPI flash memory operations */ 525 if (op->dummy.nbytes) 526 ncycles += ((op->dummy.nbytes * 8) / op->dummy.buswidth) /
Quoted 6 lines
(
op->dummy.dtr? 2 : 1);
527Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
CID 537478: Integer handling issues (
OVERFLOW_BEFORE_WIDEN)
Potentially overflowing expression "op->data.nbytes* 8U" with type "unsigned int" (32 bits, unsigned) is evaluated using 32-bit arithmetic, and then used in a context that expects an expression of type "u64" (64 bits, unsigned).528 ncycles += ((
op->data.nbytes* 8) /op->data.buswidth) /
(op->data.dtr? 2 : 1);
op->data.nbytes comes from file drivers/mtd/nand/spi/core.c, function spinand_select_op_variant().
According to the code the max value of op->data.nbytes is
nanddev_per_page_oobsize(nand) + nanddev_page_size(nand)
thus it's slightly more than 4Kb (I never seen flashes with page size large than 4Kb). According to this estimation the overflow will never happen.
If it make sense, I can try to do something with it
Regards,
Mikhail Kshevetskiy
Quoted 15 lines
529
530 return ncycles; 531 } 532 EXPORT_SYMBOL_GPL(spi_mem_calc_op_duration);533
View Defects in Coverity Scan
<https://scan.coverity.com/projects/das-u-boot?tab=overview>Best regards,
The Coverity Scan Admin Team
----- End forwarded message -----
Quoted 48 lines · Mikhail Kshevetskiy
Quoted 34 lines · Tom Rini
I think unfortunately the report email for when I merged in -next was lost somewhere / wasn't sent. I may be able to get the details out the dashboard.
---------- Forwarded message ---------
From: <[email protected]>
Date: Fri, Oct 10, 2025 at 7:08 PM
Subject: New Defects reported by Coverity Scan for Das U-Boot
To: <[email protected]>Hi,
Please find the latest report on new defect(s) introduced to *Das U-Boot* found with Coverity Scan.
- *New Defects Found:* 1
- *Defects Shown:* Showing 1 of 1 defect(s)Defect Details
** CID 537478: Integer handling issues (
OVERFLOW_BEFORE_WIDEN)
/drivers/spi/spi-mem.c: 528 inspi_mem_calc_op_duration()_____________________________________________________________________________________________
*** CID 537478: Integer handling issues (OVERFLOW_BEFORE_WIDEN)
/drivers/spi/spi-mem.c: 528 inspi_mem_calc_op_duration()
522 ncycles += ((op->addr.nbytes* 8) /op->addr.buswidth) /
(op->addr.dtr? 2 : 1);
523524 /* Dummy bytes are optional for some SPI flash memory operations */ 525 if (op->dummy.nbytes) 526 ncycles += ((op->dummy.nbytes * 8) / op->dummy.buswidth) /Quoted 6 lines
(
op->dummy.dtr? 2 : 1);
527Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
CID 537478: Integer handling issues (
OVERFLOW_BEFORE_WIDEN)
Potentially overflowing expression "op->data.nbytes* 8U" with type "unsigned int" (32 bits, unsigned) is evaluated using 32-bit arithmetic, and then used in a context that expects an expression of type "u64" (64 bits, unsigned).528 ncycles += ((
op->data.nbytes* 8) /op->data.buswidth) /
(op->data.dtr? 2 : 1);op->data.nbytes comes from file
drivers/mtd/nand/spi/core.c, functionspinand_select_op_variant().
According to the code the max value ofop->data.nbytesis
Quoted 7 lines
nanddev_per_page_oobsize(nand)+nanddev_page_size(nand)thus it's slightly more than 4Kb (I never seen flashes with page size large than 4Kb). According to this estimation the overflow will never happen.
If it make sense, I can try to do something with it
Yes, please see what you can do about it and thanks for explaining that it shouldn't be an actual problem.
Signature · 1 line
Tom
Hello Tom,
I just sent a fix for the issue in the my "coverity and 64-bit division fixes" series.
If it's needed I can split the series and send patches separately.
Regards,
Mikhail Kshevetskiy
Quoted 57 lines · Tom Rini
Quoted 46 lines · Mikhail Kshevetskiy
Quoted 34 lines · Tom Rini
I think unfortunately the report email for when I merged in -next was lost somewhere / wasn't sent. I may be able to get the details out the dashboard.
---------- Forwarded message ---------
From: <[email protected]>
Date: Fri, Oct 10, 2025 at 7:08 PM
Subject: New Defects reported by Coverity Scan for Das U-Boot
To: <[email protected]>Hi,
Please find the latest report on new defect(s) introduced to *Das U-Boot* found with Coverity Scan.
- *New Defects Found:* 1
- *Defects Shown:* Showing 1 of 1 defect(s)Defect Details
** CID 537478: Integer handling issues (
OVERFLOW_BEFORE_WIDEN)
/drivers/spi/spi-mem.c: 528 inspi_mem_calc_op_duration()_____________________________________________________________________________________________
*** CID 537478: Integer handling issues (OVERFLOW_BEFORE_WIDEN)
/drivers/spi/spi-mem.c: 528 inspi_mem_calc_op_duration()
522 ncycles += ((op->addr.nbytes* 8) /op->addr.buswidth) /
(op->addr.dtr? 2 : 1);
523524 /* Dummy bytes are optional for some SPI flash memory operations */ 525 if (op->dummy.nbytes) 526 ncycles += ((op->dummy.nbytes * 8) / op->dummy.buswidth) /Quoted 6 lines
(
op->dummy.dtr? 2 : 1);
527Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
CID 537478: Integer handling issues (
OVERFLOW_BEFORE_WIDEN)
Potentially overflowing expression "op->data.nbytes* 8U" with type "unsigned int" (32 bits, unsigned) is evaluated using 32-bit arithmetic, and then used in a context that expects an expression of type "u64" (64 bits, unsigned).528 ncycles += ((
op->data.nbytes* 8) /op->data.buswidth) /
(op->data.dtr? 2 : 1);op->data.nbytes comes from file
drivers/mtd/nand/spi/core.c, functionspinand_select_op_variant().
According to the code the max value ofop->data.nbytesisQuoted 7 lines
nanddev_per_page_oobsize(nand)+nanddev_page_size(nand)thus it's slightly more than 4Kb (I never seen flashes with page size large than 4Kb). According to this estimation the overflow will never happen.
If it make sense, I can try to do something with it
Yes, please see what you can do about it and thanks for explaining that it shouldn't be an actual problem.
On Sat, Nov 01, 2025 at 09:32:35AM +0300, Mikhail Kshevetskiy wrote:
p
Quoted 5 lines
Hello Tom,
I just sent a fix for the issue in the my "coverity and 64-bit division fixes" series.
If it's needed I can split the series and send patches separately.
Thanks, that series looks fine to me.
Signature · 1 line
Tom
Hi Tom
Quoted 5 lines · Tom Rini
On Sat, Nov 01, 2025 at 09:32:35AM +0300, Mikhail Kshevetskiy wrote:
pQuoted 2 lines
Hello Tom,
Quoted 7 lines
Quoted 3 lines
I just sent a fix for the issue in the my "coverity and 64-bit division fixes" series.
If it's needed I can split the series and send patches separately.Thanks, that series looks fine to me.
--
I will pick with other series
Michael
Quoted 1 line
Tom
Signature · 11 lines
Michael Nazzareno Trimarchi Co-Founder & Chief Executive Officer M. +39 347 913 2170 [email protected] __________________________________ Amarula Solutions BV Joop Geesinkweg 125, 1114 AB, Amsterdam, NL T. +31 (0)85 111 9172 [email protected] www.amarulasolutions.com