In get_running_kernel_version() function, we directly pass return
pointer from strtok_r() to string_is_numberical().
Return pointer from strok_r() can be NULL, but string_is_numberical()
can't handle it and will cause NULL pointer derefernces.
Fix it by check if it's a NULL pointer first.
Reported-by: David Sterba <dsterba@xxxxxxx>
Resolves-Coverity-CID: 1374097
Signed-off-by: Qu Wenruo <quwenruo@xxxxxxxxxxxxxx>
---
utils.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/utils.c b/utils.c
index 3f54245..c135ac9 100644
--- a/utils.c
+++ b/utils.c
@@ -4015,6 +4015,8 @@ unsigned int get_unit_mode_from_arg(int *argc, char *argv[], int df_mode)
int string_is_numerical(const char *str)
{
+ if (!str)
+ return 0;
if (!(*str >= '0' && *str <= '9'))
return 0;
while (*str >= '0' && *str <= '9')
--
2.10.1
--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html