From 3da12f3d5fad1c3ff6f47d7dc716302d4d5be989 Mon Sep 17 00:00:00 2001 From: Adam Borowski Date: Mon, 25 Feb 2019 19:16:43 +0100 Subject: [PATCH] btrfs-progs: fix kernel version parsing on some versions past 3.0 The code fails if the third section is missing (like "4.18") or is followed by anything but "." or "-". This happens for example if we're not exactly at a tag and CONFIG_LOCALVERSION_AUTO=n (which results in "4.18.5+"). Signed-off-by: Adam Borowski Signed-off-by: David Sterba --- fsfeatures.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/fsfeatures.c b/fsfeatures.c index 13ad0308..7f3ef03b 100644 --- a/fsfeatures.c +++ b/fsfeatures.c @@ -216,11 +216,9 @@ u32 get_running_kernel_version(void) return (u32)-1; version |= atoi(tmp) << 8; tmp = strtok_r(NULL, ".", &saveptr); - if (tmp) { - if (!string_is_numerical(tmp)) - return (u32)-1; + /* Relaxed format accepts eg. 1.2.3+ */ + if (tmp && string_is_numerical(tmp)) version |= atoi(tmp); - } return version; }