Skip to contentSkip to conversation

arm: mvebu: avoid possible NULL dereference

PATCH New Heinrich Schuchardt 3 participants 3 messages Jul 30, 2017 – Aug 14, 2017

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 arm: mvebu: avoid possible NULL dereference

It does not make sense to check if info is NULL after dereferencing it.

The problem was indicated by cppcheck.

---
 arch/arm/mach-mvebu/serdes/axp/high_speed_env_lib.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
arch/arm/mach-mvebu/serdes/axp/high_speed_env_lib.c +5 -5
index b0e193b78c..525576a4fc 100644
@@ -354,16 +354,16 @@ int serdes_phy_config(void)
 	}
 
 	info = board_serdes_cfg_get(PEX_MODE_GET(satr11));
-	DEBUG_INIT_FULL_S("info->line0_7= 0x");
-	DEBUG_INIT_FULL_D(info->line0_7, 8);
-	DEBUG_INIT_FULL_S("   info->line8_15= 0x");
-	DEBUG_INIT_FULL_D(info->line8_15, 8);
-	DEBUG_INIT_FULL_S("\n");
 
 	if (info == NULL) {
 		DEBUG_INIT_S("Hight speed PHY Error #1\n");
 		return MV_ERROR;
 	}
+	DEBUG_INIT_FULL_S("info->line0_7= 0x");
+	DEBUG_INIT_FULL_D(info->line0_7, 8);
+	DEBUG_INIT_FULL_S("   info->line8_15= 0x");
+	DEBUG_INIT_FULL_D(info->line8_15, 8);
+	DEBUG_INIT_FULL_S("\n");
 
 	if (config_module & ETM_MODULE_DETECT) {	/* step 0.9 ETM */
 		DEBUG_INIT_FULL_S("ETM module detect Step 0.9:\n");
Signature · 1 line
2.13.2
#1 lore raw

PATCH 1/1 arm: mvebu: avoid possible NULL dereference

Quoted 27 lines · Heinrich Schuchardt

It does not make sense to check if info is NULL after dereferencing it.

The problem was indicated by cppcheck.

---
  arch/arm/mach-mvebu/serdes/axp/high_speed_env_lib.c | 10 +++++-----
  1 file changed, 5 insertions(+), 5 deletions(-)
arch/arm/mach-mvebu/serdes/axp/high_speed_env_lib.c +0 -5
index b0e193b78c..525576a4fc 100644
@@ -354,16 +354,16 @@ int serdes_phy_config(void)
  	}
 
  	info = board_serdes_cfg_get(PEX_MODE_GET(satr11));
-	DEBUG_INIT_FULL_S("info->line0_7= 0x");
-	DEBUG_INIT_FULL_D(info->line0_7, 8);
-	DEBUG_INIT_FULL_S("   info->line8_15= 0x");
-	DEBUG_INIT_FULL_D(info->line8_15, 8);
-	DEBUG_INIT_FULL_S("\n");
 
  	if (info == NULL) {
  		DEBUG_INIT_S("Hight speed PHY Error #1\n");

arch/arm/mach-mvebu/serdes/axp/high_speed_env_lib.c int serdes_phy_config(void) · line 369

Quoted 10 lines
arch/arm/mach-mvebu/serdes/axp/high_speed_env_lib.c +5 -0
  		return MV_ERROR;
  	}
+	DEBUG_INIT_FULL_S("info->line0_7= 0x");
+	DEBUG_INIT_FULL_D(info->line0_7, 8);
+	DEBUG_INIT_FULL_S("   info->line8_15= 0x");
+	DEBUG_INIT_FULL_D(info->line8_15, 8);
+	DEBUG_INIT_FULL_S("\n");
 
  	if (config_module & ETM_MODULE_DETECT) {	/* step 0.9 ETM */
  		DEBUG_INIT_FULL_S("ETM module detect Step 0.9:\n");

Thanks,
Stefan

#2 lore raw

PATCH 1/1 arm: mvebu: avoid possible NULL dereference

In reply to Heinrich Schuchardt
Quoted 7 lines · xypron.glpk at gmx.de

It does not make sense to check if info is NULL after dereferencing it.

The problem was indicated by cppcheck.

Applied to u-boot/master, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20170813/786d2f75/attachment.sig>