Skip to contentSkip to conversation

[[email protected]: Fwd: New Defects reported by Coverity Scan for Das U-Boot]

[email protected]: Fwd: New Defects reported by Coverity Scan for Das U-Boot Tom Rini 2 participants 3 messages Dec 18, 2023 – Dec 21, 2023

lore
Share & tools
lore

Tom Rini

author
#0 lore raw

Here's the latest report.

---------- Forwarded message ---------
From: <[email protected]>
Date: Mon, Dec 18, 2023 at 8:42 AM
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.

New defect(s) Reported-by: Coverity Scan
Showing 1 of 1 defect(s)

** CID 470930: Uninitialized variables (UNINIT)
/boot/bootmeth_efi.c: 465 in distro_efi_boot()

________________________________________________________________________________________________________
*** CID 470930: Uninitialized variables (UNINIT) /boot/bootmeth_efi.c: 465 in distro_efi_boot()
459 */
460 if (bflow->flags & BOOTFLOWF_USE_BUILTIN_FDT) {
461 log_debug("Booting with built-in fdt\n");
462 snprintf(cmd, sizeof(cmd), "bootefi %lx", kernel);
463 } else {
464 log_debug("Booting with external fdt\n");

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

CID 470930: Uninitialized variables (UNINIT)
Using uninitialized value "fdt" when calling "snprintf". [Note: The source code implementation of the function has been overridden by a builtin model.]

465 snprintf(cmd, sizeof(cmd), "bootefi %lx %lx",
kernel, fdt);
466 }
467
468 if (run_command(cmd, 0))
469 return log_msg_ret("run", -EINVAL);
470

Signature · 1 line
Tom
#1 lore raw

Hi Tom,

Quoted 37 lines · Tom Rini

Here's the latest report.

---------- Forwarded message ---------
From: <[email protected]>
Date: Mon, Dec 18, 2023 at 8:42 AM
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.

New defect(s) Reported-by: Coverity Scan
Showing 1 of 1 defect(s)

** CID 470930: Uninitialized variables (UNINIT)
/boot/bootmeth_efi.c: 465 in distro_efi_boot()

________________________________________________________________________________________________________
*** CID 470930: Uninitialized variables (UNINIT) /boot/bootmeth_efi.c: 465 in distro_efi_boot()
459 */
460 if (bflow->flags & BOOTFLOWF_USE_BUILTIN_FDT) {
461 log_debug("Booting with built-in fdt\n");
462 snprintf(cmd, sizeof(cmd), "bootefi %lx", kernel);
463 } else {
464 log_debug("Booting with external fdt\n");

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

CID 470930: Uninitialized variables (UNINIT)
Using uninitialized value "fdt" when calling "snprintf". [Note: The source code implementation of the function has been overridden by a builtin model.]

Quoted 8 lines

465 snprintf(cmd, sizeof(cmd), "bootefi %lx %lx",
kernel, fdt);
466 }
467
468 if (run_command(cmd, 0))
469 return log_msg_ret("run", -EINVAL);
470

The code in question is

if (!bootmeth_uses_network(bflow)) {
// snip
if (bflow->flags & ~BOOTFLOWF_USE_BUILTIN_FDT)

    fdt = bflow->fdt_addr;
} else {

// snip
fdt = env_get_hex("fdt_addr_r", 0);
}
//snip
if (bflow->flags & BOOTFLOWF_USE_BUILTIN_FDT) {
log_debug("Booting with built-in fdt\n"); snprintf(cmd, sizeof(cmd), "bootefi %lx", kernel);
} else {
log_debug("Booting with external fdt\n"); snprintf(cmd, sizeof(cmd), "bootefi %lx %lx", kernel, fdt);
}

I am unsure in which case is fdt uninitialised. Unless the tool is being thrown off by different version of bflow->flags & BOOTFLOWF_USE_BUILTIN_FDT
check, I don't see the problem.

Please let me know if you see it.

Kind regards,
Shantur

Quoted 3 lines

--
Tom

author
#2 lore raw
Quoted 68 lines · Shantur Rathore

Hi Tom,

Quoted 37 lines · Tom Rini

Here's the latest report.

---------- Forwarded message ---------
From: <[email protected]>
Date: Mon, Dec 18, 2023 at 8:42 AM
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.

New defect(s) Reported-by: Coverity Scan
Showing 1 of 1 defect(s)

** CID 470930: Uninitialized variables (UNINIT)
/boot/bootmeth_efi.c: 465 in distro_efi_boot()

________________________________________________________________________________________________________
*** CID 470930: Uninitialized variables (UNINIT) /boot/bootmeth_efi.c: 465 in distro_efi_boot()
459 */
460 if (bflow->flags & BOOTFLOWF_USE_BUILTIN_FDT) {
461 log_debug("Booting with built-in fdt\n");
462 snprintf(cmd, sizeof(cmd), "bootefi %lx", kernel);
463 } else {
464 log_debug("Booting with external fdt\n");

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

CID 470930: Uninitialized variables (UNINIT)
Using uninitialized value "fdt" when calling "snprintf". [Note: The source code implementation of the function has been overridden by a builtin model.]

Quoted 8 lines

465 snprintf(cmd, sizeof(cmd), "bootefi %lx %lx",
kernel, fdt);
466 }
467
468 if (run_command(cmd, 0))
469 return log_msg_ret("run", -EINVAL);
470

The code in question is

if (!bootmeth_uses_network(bflow)) {
// snip
if (bflow->flags & ~BOOTFLOWF_USE_BUILTIN_FDT)

    fdt = bflow->fdt_addr;
} else {

// snip
fdt = env_get_hex("fdt_addr_r", 0);
}
//snip
if (bflow->flags & BOOTFLOWF_USE_BUILTIN_FDT) {
log_debug("Booting with built-in fdt\n"); snprintf(cmd, sizeof(cmd), "bootefi %lx", kernel);
} else {
log_debug("Booting with external fdt\n"); snprintf(cmd, sizeof(cmd), "bootefi %lx %lx", kernel, fdt);
}

Quoted 6 lines

I am unsure in which case is fdt uninitialised. Unless the tool is being thrown off by different version of bflow->flags & BOOTFLOWF_USE_BUILTIN_FDT
check, I don't see the problem.

Please let me know if you see it.

Ah, right, thanks for re-checking.

Signature · 1 line
Tom