New Defects reported by Coverity Scan for Das U-Boot
Here's the latest report. Getting closer with the led change. I do wish it was easier to test fixes here.
---------- Forwarded message ---------
From: <[email protected]>
Date: Mon, Feb 24, 2025, 5:05 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.
1 new defect(s) introduced to Das U-Boot found with Coverity Scan. 2 defect(s), reported by Coverity Scan earlier, were marked fixed in the recent build analyzed by Coverity Scan.
New defect(s) Reported-by: Coverity Scan
Showing 1 of 1 defect(s)
** CID 542488: Control flow issues (NO_EFFECT) /drivers/led/led-uclass.c: 277 in led_get_function_name()
________________________________________________________________________________________________________
*** CID 542488: Control flow issues (NO_EFFECT) /drivers/led/led-uclass.c: 277 in led_get_function_name()
271 return uc_plat->label;
272
273 /* Now try to detect function label name */ 274 func = dev_read_string(dev, "function"); 275 cp = dev_read_u32(dev, "color", &color); 276 // prevent coverity scan error CID 541279: (TAINTED_SCALAR)
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
CID 542488: Control flow issues (
NO_EFFECT)
This less-than-zero comparison of an unsigned value is never true.
"color < 0U".
277 if (color < LED_COLOR_ID_WHITE || color >= LED_COLOR_ID_MAX)
278 cp = -EINVAL;
279
280 if (cp == 0 || func) {
281 ret = dev_read_u32(dev, "function-enumerator",
&enumerator);
282 if (!ret) {
----- End forwarded message -----
Signature · 1 line
Tom
Hello Tom,
Quoted 2 lines · Tom Rini
Here's the latest report. Getting closer with the led change. I do wish it was easier to test fixes here.
Yes...
Quoted 33 lines
---------- Forwarded message ---------
From: <[email protected]>
Date: Mon, Feb 24, 2025, 5:05 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.
1 new defect(s) introduced to Das U-Boot found with Coverity Scan. 2 defect(s), reported by Coverity Scan earlier, were marked fixed in the recent build analyzed by Coverity Scan.
New defect(s) Reported-by: Coverity Scan
Showing 1 of 1 defect(s)** CID 542488: Control flow issues (
NO_EFFECT) /drivers/led/led-uclass.c: 277 inled_get_function_name()________________________________________________________________________________________________________
*** CID 542488: Control flow issues (NO_EFFECT) /drivers/led/led-uclass.c: 277 inled_get_function_name()
271 returnuc_plat->label;
272273 /* Now try to detect function label name */ 274 func = dev_read_string(dev, "function"); 275 cp = dev_read_u32(dev, "color", &color); 276 // prevent coverity scan error CID 541279: (TAINTED_SCALAR)
Quoted 5 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
CID 542488: Control flow issues (
NO_EFFECT)
This less-than-zero comparison of an unsigned value is never true."color < 0U".
277 if (color <LED_COLOR_ID_WHITE|| color >=LED_COLOR_ID_MAX)
278 cp =-EINVAL;
So I simply remove this check ... and add a comment that LED_COLOR_ID_WHITE must be 0...
Quoted 8 lines
279
280 if (cp == 0 || func) {
281 ret = dev_read_u32(dev, "function-enumerator",
&enumerator);
282 if (!ret) {----- End forwarded message -----
Send the fix, when CI succeeds:
https://dev.azure.com/hs0298/hs/_build/results?buildId=171&view=results
Thanks for the report.
bye,
Heiko
Signature · 3 lines
DENX Software Engineering GmbH, Managing Director: Erika Unter HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: +49-8142-66989-52 Fax: +49-8142-66989-80 Email: [email protected]
Hi Heiko,
Quoted 41 lines · Heiko Schocher
Hello Tom,
Quoted 2 lines · Tom Rini
Here's the latest report. Getting closer with the led change. I do wish it was easier to test fixes here.
Yes...
Quoted 33 lines
---------- Forwarded message ---------
From: <[email protected]>
Date: Mon, Feb 24, 2025, 5:05 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.
1 new defect(s) introduced to Das U-Boot found with Coverity Scan. 2 defect(s), reported by Coverity Scan earlier, were marked fixed in the recent build analyzed by Coverity Scan.
New defect(s) Reported-by: Coverity Scan
Showing 1 of 1 defect(s)** CID 542488: Control flow issues (
NO_EFFECT) /drivers/led/led-uclass.c: 277 inled_get_function_name()________________________________________________________________________________________________________
*** CID 542488: Control flow issues (NO_EFFECT) /drivers/led/led-uclass.c: 277 inled_get_function_name()
271 returnuc_plat->label;
272
273 /* Now try to detect function label name */
274 func =dev_read_string(dev, "function");
275 cp =dev_read_u32(dev, "color", &color);
276 // prevent coverity scan error CID 541279: (TAINTED_SCALAR)
Quoted 9 lines
Quoted 5 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
CID 542488: Control flow issues (
NO_EFFECT)
This less-than-zero comparison of an unsigned value is never true."color < 0U".
277 if (color <LED_COLOR_ID_WHITE|| color >=LED_COLOR_ID_MAX) 278 cp =-EINVAL;So I simply remove this check ... and add a comment that
LED_COLOR_ID_WHITEmust be 0...
It's part of the binding from the kernel, I assume it's safe to assume it'll be 0?
Also, this is guaranteed by the fact color is a u32 in led_get_function_name, so it cannot be < 0.
Cheers,
Quentin
Hello Quentin,
Quoted 51 lines · Quentin Schulz
Hi Heiko,
Quoted 48 lines · Heiko Schocher
Hello Tom,
Quoted 2 lines · Tom Rini
Here's the latest report. Getting closer with the led change. I do wish it was easier to test fixes here.
Yes...
Quoted 39 lines
---------- Forwarded message ---------
From: <[email protected]>
Date: Mon, Feb 24, 2025, 5:05 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.
1 new defect(s) introduced to Das U-Boot found with Coverity Scan. 2 defect(s), reported by Coverity Scan earlier, were marked fixed in the recent build analyzed by Coverity Scan.
New defect(s) Reported-by: Coverity Scan
Showing 1 of 1 defect(s)** CID 542488: Control flow issues (
NO_EFFECT) /drivers/led/led-uclass.c: 277 inled_get_function_name()________________________________________________________________________________________________________
*** CID 542488: Control flow issues (
NO_EFFECT) /drivers/led/led-uclass.c: 277 inled_get_function_name()
271 returnuc_plat->label;
272
273 /* Now try to detect function label name */
274 func =dev_read_string(dev, "function");
275 cp =dev_read_u32(dev, "color", &color);
276 // prevent coverity scan error CID 541279: (TAINTED_SCALAR)Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
CID 542488: Control flow issues (
NO_EFFECT)
This less-than-zero comparison of an unsigned value is never true."color < 0U".
277 if (color <LED_COLOR_ID_WHITE|| color >=LED_COLOR_ID_MAX) 278 cp =-EINVAL;
Quoted 5 lines
Quoted 3 lines
So I simply remove this check ... and add a comment that
LED_COLOR_ID_WHITEmust be 0...It's part of the binding from the kernel, I assume it's safe to assume it'll be 0?
Yes it is.
Quoted 1 line
Also, this is guaranteed by the fact color is a u32 in
led_get_function_name, so it cannot be < 0.
Posted a fix, see:
http://patchwork.ozlabs.org/project/uboot/patch/[email protected]/
added a comment @LED_COLOR_ID_WHITE definition, so in case someone wants to move LED_COLOR_ID_WHITE to another value... may it helps.
Thanks!
bye,
Heiko
Signature · 3 lines
DENX Software Engineering GmbH, Managing Director: Erika Unter HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: +49-8142-66989-52 Fax: +49-8142-66989-80 Email: [email protected]