Commit c41cb902 authored by Ofir Bitton's avatar Ofir Bitton Committed by Greg Kroah-Hartman

habanalabs: parse full firmware versions

When parsing firmware versions strings, driver should not
assume a specific length and parse up to the maximum supported
version length.
Signed-off-by: default avatarOfir Bitton <obitton@habana.ai>
Reviewed-by: default avatarOded Gabbay <ogabbay@kernel.org>
Signed-off-by: default avatarOded Gabbay <ogabbay@kernel.org>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 9d92689c
...@@ -18,8 +18,9 @@ ...@@ -18,8 +18,9 @@
static char *extract_fw_ver_from_str(const char *fw_str) static char *extract_fw_ver_from_str(const char *fw_str)
{ {
char *str, *fw_ver, *whitespace; char *str, *fw_ver, *whitespace;
u32 ver_offset;
fw_ver = kmalloc(16, GFP_KERNEL); fw_ver = kmalloc(VERSION_MAX_LEN, GFP_KERNEL);
if (!fw_ver) if (!fw_ver)
return NULL; return NULL;
...@@ -29,9 +30,10 @@ static char *extract_fw_ver_from_str(const char *fw_str) ...@@ -29,9 +30,10 @@ static char *extract_fw_ver_from_str(const char *fw_str)
/* Skip the fw- part */ /* Skip the fw- part */
str += 3; str += 3;
ver_offset = str - fw_str;
/* Copy until the next whitespace */ /* Copy until the next whitespace */
whitespace = strnstr(str, " ", 15); whitespace = strnstr(str, " ", VERSION_MAX_LEN - ver_offset);
if (!whitespace) if (!whitespace)
goto free_fw_ver; goto free_fw_ver;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment