Skip to contentSkip to conversation

Fix coverity issues for AST2700

PATCH Applied Jamin Lin via 4 participants 6 messages Jun 25, 2024 – Jul 2, 2024 Arm/Aspeed machine support

lore
Share & tools
lore
#0 lore raw

v3 cover Fix coverity issues for AST2700

change from v1:
aspeed/soc: coverity defect: DIVIDE_BY_ZERO aspeed/sdmc: coverity defect: Control flow issues (DEADCODE)

change from v2:
add more commit log from reviewer suggestion, Cédric.

change from v3:
replace qemu_log_mask with assert dram size 0.

Jamin Lin (2):
aspeed/soc: Fix possible divide by zero
aspeed/sdmc: Remove extra R_MAIN_STATUS case

 hw/arm/aspeed_ast27x0.c | 2 ++
 hw/misc/aspeed_sdmc.c   | 1 -
 2 files changed, 2 insertions(+), 1 deletion(-)
Signature · 1 line
2.25.1
#1 lore raw

PATCH v3 1/2 aspeed/soc: Fix possible divide by zero

Coverity reports a possible DIVIDE_BY_ZERO issue regarding the "ram_size" object property. This can not happen because RAM has predefined valid sizes per SoC. Nevertheless, add a test to close the issue.

Fixes Coverity CID 1547113
[ clg: Rewrote commit log ]
---
 hw/arm/aspeed_ast27x0.c | 2 ++
 1 file changed, 2 insertions(+)
hw/arm/aspeed_ast27x0.c +2 -0
index b6876b4862..18e6a8b10c 100644
@@ -211,6 +211,8 @@ static void aspeed_ram_capacity_write(void *opaque, hwaddr addr, uint64_t data,
     ram_size = object_property_get_uint(OBJECT(&s->sdmc), "ram-size",
                                         &error_abort);
 
+    assert(ram_size > 0);
+
     /*
      * Emulate ddr capacity hardware behavior.
      * If writes the data to the address which is beyond the ram size,
Signature · 1 line
2.25.1
#2 lore raw

PATCH v3 2/2 aspeed/sdmc: Remove extra R_MAIN_STATUS case

In reply to Jamin Lin via

Coverity reports that the newly added 'case R_MAIN_STATUS' is DEADCODE because it can not be reached. This is because R_MAIN_STATUS is handled before in the "Unprotected registers" switch statement. Remove it.

Fixes Coverity CID 1547112
[ clg: Rewrote commit log ]
---
 hw/misc/aspeed_sdmc.c | 1 -
 1 file changed, 1 deletion(-)
hw/misc/aspeed_sdmc.c +0 -1
index 93e2e29ead..94eed9264d 100644
@@ -589,7 +589,6 @@ static void aspeed_2700_sdmc_write(AspeedSDMCState *s, uint32_t reg,
     case R_INT_STATUS:
     case R_INT_CLEAR:
     case R_INT_MASK:
-    case R_MAIN_STATUS:
     case R_ERR_STATUS:
     case R_ECC_FAIL_STATUS:
     case R_ECC_FAIL_ADDR:
Signature · 1 line
2.25.1
#3 lore raw
In reply to Jamin Lin via

Hello Jamin

Quoted 10 lines · Jamin Lin

change from v1:
aspeed/soc: coverity defect: DIVIDE_BY_ZERO aspeed/sdmc: coverity defect: Control flow issues (DEADCODE)

change from v2:
add more commit log from reviewer suggestion, Cédric.

change from v3:
replace qemu_log_mask with assert dram size 0.

Quoted 8 lines

Jamin Lin (2):
aspeed/soc: Fix possible divide by zero
aspeed/sdmc: Remove extra R_MAIN_STATUS case

  hw/arm/aspeed_ast27x0.c | 2 ++
  hw/misc/aspeed_sdmc.c   | 1 -
  2 files changed, 2 insertions(+), 1 deletion(-)

LGTM.

Could you please review :

https://lore.kernel.org/qemu-devel/[email protected]/T/#u

Thanks,

C.

#4 lore raw

Hi Cedric,

Quoted 28 lines

-----Original Message-----
From: Cédric Le Goater <[email protected]>
Sent: Tuesday, June 25, 2024 3:22 PM
To: Jamin Lin <[email protected]>; Peter Maydell <[email protected]>; Steven Lee <[email protected]>; Troy Lee <[email protected]>; Andrew Jeffery <[email protected]>; Joel Stanley <[email protected]>; open list:ASPEED BMCs <[email protected]>; open list:All patches CC here <[email protected]>
Subject: Re: [PATCH v3 0/2] Fix coverity issues for AST2700

Hello Jamin

Quoted 14 lines · Jamin Lin

change from v1:
aspeed/soc: coverity defect: DIVIDE_BY_ZERO aspeed/sdmc: coverity defect: Control flow issues (DEADCODE)

change from v2:
add more commit log from reviewer suggestion, Cédric.

change from v3:
replace qemu_log_mask with assert dram size 0.

Jamin Lin (2):
aspeed/soc: Fix possible divide by zero
aspeed/sdmc: Remove extra R_MAIN_STATUS case

Quoted 9 lines
Quoted 4 lines
  hw/arm/aspeed_ast27x0.c | 2 ++
  hw/misc/aspeed_sdmc.c   | 1 -
  2 files changed, 2 insertions(+), 1 deletion(-)

LGTM.

Could you please review :

Done.
Thanks-Jamin

Quoted 7 lines

https://lore.kernel.org/qemu-devel/[email protected]
m/T/#u

Thanks,

C.

#5 lore raw
In reply to Jamin Lin via
Quoted 10 lines · Jamin Lin

change from v1:
aspeed/soc: coverity defect: DIVIDE_BY_ZERO aspeed/sdmc: coverity defect: Control flow issues (DEADCODE)

change from v2:
add more commit log from reviewer suggestion, Cédric.

change from v3:
replace qemu_log_mask with assert dram size 0.

Quoted 8 lines

Jamin Lin (2):
aspeed/soc: Fix possible divide by zero
aspeed/sdmc: Remove extra R_MAIN_STATUS case

  hw/arm/aspeed_ast27x0.c | 2 ++
  hw/misc/aspeed_sdmc.c   | 1 -
  2 files changed, 2 insertions(+), 1 deletion(-)

Applied to aspeed-next.

Thanks,

C.