diff mbox

[U-Boot,1/1] arm: mvebu: avoid possible NULL dereference

Message ID 20170730184043.9467-1-xypron.glpk@gmx.de
State Accepted
Commit a22bbfda6edd3cba79496b9d02077d5ae64ff4b0
Delegated to: Tom Rini
Headers show

Commit Message

Heinrich Schuchardt July 30, 2017, 6:40 p.m. UTC
It does not make sense to check if info is NULL after
dereferencing it.

The problem was indicated by cppcheck.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
---
 arch/arm/mach-mvebu/serdes/axp/high_speed_env_lib.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

Comments

Stefan Roese Aug. 8, 2017, 12:17 p.m. UTC | #1
On 30.07.2017 20:40, Heinrich Schuchardt wrote:
> It does not make sense to check if info is NULL after
> dereferencing it.
> 
> The problem was indicated by cppcheck.
> 
> Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
> ---
>   arch/arm/mach-mvebu/serdes/axp/high_speed_env_lib.c | 10 +++++-----
>   1 file changed, 5 insertions(+), 5 deletions(-)
> 
> diff --git a/arch/arm/mach-mvebu/serdes/axp/high_speed_env_lib.c b/arch/arm/mach-mvebu/serdes/axp/high_speed_env_lib.c
> index b0e193b78c..525576a4fc 100644
> --- a/arch/arm/mach-mvebu/serdes/axp/high_speed_env_lib.c
> +++ b/arch/arm/mach-mvebu/serdes/axp/high_speed_env_lib.c
> @@ -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");
> 

Reviewed-by: Stefan Roese <sr@denx.de>

Thanks,
Stefan
Tom Rini Aug. 14, 2017, 12:07 a.m. UTC | #2
On Sun, Jul 30, 2017 at 08:40:43PM +0200, xypron.glpk@gmx.de wrote:

> It does not make sense to check if info is NULL after
> dereferencing it.
> 
> The problem was indicated by cppcheck.
> 
> Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
> Reviewed-by: Stefan Roese <sr@denx.de>

Applied to u-boot/master, thanks!
diff mbox

Patch

diff --git a/arch/arm/mach-mvebu/serdes/axp/high_speed_env_lib.c b/arch/arm/mach-mvebu/serdes/axp/high_speed_env_lib.c
index b0e193b78c..525576a4fc 100644
--- a/arch/arm/mach-mvebu/serdes/axp/high_speed_env_lib.c
+++ b/arch/arm/mach-mvebu/serdes/axp/high_speed_env_lib.c
@@ -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");