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: Ofir Bitton <obitton@habana.ai> Reviewed-by: Oded Gabbay <ogabbay@kernel.org> Signed-off-by: Oded Gabbay <ogabbay@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
9d92689ca2
commit
c41cb902b2
|
@ -18,8 +18,9 @@
|
|||
static char *extract_fw_ver_from_str(const char *fw_str)
|
||||
{
|
||||
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)
|
||||
return NULL;
|
||||
|
||||
|
@ -29,9 +30,10 @@ static char *extract_fw_ver_from_str(const char *fw_str)
|
|||
|
||||
/* Skip the fw- part */
|
||||
str += 3;
|
||||
ver_offset = str - fw_str;
|
||||
|
||||
/* Copy until the next whitespace */
|
||||
whitespace = strnstr(str, " ", 15);
|
||||
whitespace = strnstr(str, " ", VERSION_MAX_LEN - ver_offset);
|
||||
if (!whitespace)
|
||||
goto free_fw_ver;
|
||||
|
||||
|
|
Loading…
Reference in New Issue