Skip to contentSkip to conversation

New Defects reported by Coverity Scan for Das U-Boot

DISCUSSION Tom Rini 3 participants 4 messages Jun 22 – Jun 26

lore
Share & tools
lore

Tom Rini

author
#0 lore raw

Hey all,

Coverity is back up finally and so here's the result of changes for the last three RCs.

---------- Forwarded message ---------
From: <[email protected]>
Date: Mon, Jun 22, 2026 at 4:40 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
- 4 defect(s), reported by Coverity Scan earlier, were marked fixed in the recent build analyzed by Coverity Scan.
- *Defects Shown:* Showing 1 of 1 defect(s)

Defect Details

** CID 646439: Integer handling issues (INTEGER_OVERFLOW)
/test/cmd/part.c: 53 in setup_gpt_partitions()

_____________________________________________________________________________________________
*** CID 646439: Integer handling issues (INTEGER_OVERFLOW)
/test/cmd/part.c: 53 in setup_gpt_partitions()
47 snprintf(dev_str, sizeof(dev_str), "%u", mmc_dev_num);
48

49     	ret = blk_get_device_by_str("mmc", dev_str, &mmc_dev_desc);
50     	if (ret == -ENODEV)
51     		return -EAGAIN;

52

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

CID 646439: Integer handling issues (INTEGER_OVERFLOW)
Expression "_val2", where "ret" is known to be equal to -22, overflows the type of "_val2", which is type "unsigned int".

53 ut_asserteq(mmc_dev_num, ret);
54

55     	if (CONFIG_IS_ENABLED(RANDOM_UUID)) {
56     		for (i = 0; i < ARRAY_SIZE(gpt_parts); i++)
57     			gen_rand_uuid_str(gpt_parts[i].uuid,
58     					  UUID_STR_FORMAT_STD);

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
#1 lore raw

Hi Tom,

Quoted 33 lines · Tom Rini

Hey all,

Coverity is back up finally and so here's the result of changes for the last three RCs.

---------- Forwarded message ---------
From: <[email protected]>
Date: Mon, Jun 22, 2026 at 4:40 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
- 4 defect(s), reported by Coverity Scan earlier, were marked fixed in the recent build analyzed by Coverity Scan.
- *Defects Shown:* Showing 1 of 1 defect(s)

Defect Details

** CID 646439: Integer handling issues (INTEGER_OVERFLOW)
/test/cmd/part.c: 53 in setup_gpt_partitions()

_____________________________________________________________________________________________
*** CID 646439: Integer handling issues (INTEGER_OVERFLOW)
/test/cmd/part.c: 53 in setup_gpt_partitions()
47 snprintf(dev_str, sizeof(dev_str), "%u", mmc_dev_num);
48

Quoted 8 lines
49     	ret = blk_get_device_by_str("mmc", dev_str, &mmc_dev_desc);
50     	if (ret == -ENODEV)
51     		return -EAGAIN;

52

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

CID 646439: Integer handling issues (INTEGER_OVERFLOW)
Expression "_val2", where "ret" is known to be equal to -22, overflows the type of "_val2", which is type "unsigned int".

53 ut_asserteq(mmc_dev_num, ret);
54

Does Coverity complain if we do:

ut_assert(ret >= 0);
ut_asserteq(mmc_dev_num, ret);

?

We also use the same ut_asserteq() check in many oher places with the return value of blk_get_device_by_str() so I'm surprised it doesn't complain about those and why.

Cheers,
Quentin

#2 lore raw

Hello all,

Quoted 51 lines · Quentin Schulz

Hi Tom,

Quoted 37 lines · Tom Rini

Hey all,

Coverity is back up finally and so here's the result of changes for the last three RCs.

---------- Forwarded message ---------
From: <[email protected]>
Date: Mon, Jun 22, 2026 at 4:40 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
- 4 defect(s), reported by Coverity Scan earlier, were marked fixed in the recent build analyzed by Coverity Scan.
- *Defects Shown:* Showing 1 of 1 defect(s)

Defect Details

** CID 646439: Integer handling issues (INTEGER_OVERFLOW)
/test/cmd/part.c: 53 in setup_gpt_partitions()

_____________________________________________________________________________________________
*** CID 646439: Integer handling issues (INTEGER_OVERFLOW)
/test/cmd/part.c: 53 in setup_gpt_partitions()
47 snprintf(dev_str, sizeof(dev_str), "%u", mmc_dev_num);
48
49 ret = blk_get_device_by_str("mmc", dev_str, &mmc_dev_desc);
50 if (ret == -ENODEV)
51 return -EAGAIN;
52

Quoted 4 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

CID 646439: Integer handling issues (INTEGER_OVERFLOW)
Expression "_val2", where "ret" is known to be equal to -22, overflows the type of "_val2", which is type "unsigned int".

53 ut_asserteq(mmc_dev_num, ret);
54

Does Coverity complain if we do:

ut_assert(ret >= 0);
ut_asserteq(mmc_dev_num, ret);

Quoted 8 lines

?

We also use the same ut_asserteq() check in many oher places with the return value of blk_get_device_by_str() so I'm surprised it doesn't complain about those and why.

Cheers,
Quentin

I already had the patch ready; I'm uploading it now.

Thanks and regards,
Dario

Signature · 9 lines
Dario Binacchi
Senior Embedded Software Engineer
M. +39 328 0625246
[email protected]
―――――――――――――――
Amarula Solutions SRL
 Via Felice Cavallotti 25D, 41012 Carpi, MO, IT
[email protected]
www.amarulasolutions.com
author
#3 lore raw
In reply to Quentin Schulz
Quoted 45 lines · Quentin Schulz

Hi Tom,

Quoted 33 lines · Tom Rini

Hey all,

Coverity is back up finally and so here's the result of changes for the last three RCs.

---------- Forwarded message ---------
From: <[email protected]>
Date: Mon, Jun 22, 2026 at 4:40 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
- 4 defect(s), reported by Coverity Scan earlier, were marked fixed in the recent build analyzed by Coverity Scan.
- *Defects Shown:* Showing 1 of 1 defect(s)

Defect Details

** CID 646439: Integer handling issues (INTEGER_OVERFLOW)
/test/cmd/part.c: 53 in setup_gpt_partitions()

_____________________________________________________________________________________________
*** CID 646439: Integer handling issues (INTEGER_OVERFLOW)
/test/cmd/part.c: 53 in setup_gpt_partitions()
47 snprintf(dev_str, sizeof(dev_str), "%u", mmc_dev_num);
48

Quoted 8 lines
49     	ret = blk_get_device_by_str("mmc", dev_str, &mmc_dev_desc);
50     	if (ret == -ENODEV)
51     		return -EAGAIN;

52

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

CID 646439: Integer handling issues (INTEGER_OVERFLOW)
Expression "_val2", where "ret" is known to be equal to -22, overflows the type of "_val2", which is type "unsigned int".

53 ut_asserteq(mmc_dev_num, ret);
54

Quoted 6 lines

Does Coverity complain if we do:

ut_assert(ret >= 0);
ut_asserteq(mmc_dev_num, ret);

?

I wish it was easier to test questions like that.

Quoted 3 lines

We also use the same ut_asserteq() check in many oher places with the return value of blk_get_device_by_str() so I'm surprised it doesn't complain about those and why.

Looking at open issues on test/lib/lmb.c, which has a "ut_assert(ret >= 0)" in it, and is happy with it, yes, we should be able to make changes as you suggest I believe.

Signature · 1 line
Tom