[Skiboot] [PATCH 2/6] check for NULL input string in is_sai_loc_code

Balbir singh bsingharora at gmail.com
Fri May 18 09:31:01 AEST 2018


Caught by scan-build, also constant-ify the input
parameter.

Signed-off-by: Balbir singh <bsingharora at gmail.com>
---
 hw/fsp/fsp-leds.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/hw/fsp/fsp-leds.c b/hw/fsp/fsp-leds.c
index 0fe03094..9040c0a4 100644
--- a/hw/fsp/fsp-leds.c
+++ b/hw/fsp/fsp-leds.c
@@ -203,9 +203,12 @@ static inline void opal_led_update_complete(u64 async_token, u64 result)
 	opal_queue_msg(OPAL_MSG_ASYNC_COMP, NULL, NULL, async_token, result);
 }
 
-static inline bool is_sai_loc_code(char *loc_code)
+static inline bool is_sai_loc_code(const char *loc_code)
 {
-	if (!strcmp(sai_data.loc_code, loc_code))
+	if (!loc_code)
+		return false;
+
+	if (!strncmp(sai_data.loc_code, loc_code, strlen(sai_data.loc_code)))
 		return true;
 
 	return false;
-- 
2.17.0



More information about the Skiboot mailing list