Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Fix kernel version sublevel on 4.14 branch #60

Merged
merged 1 commit into from
Nov 16, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions kernel_version.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,13 @@ func KernelVersionFromReleaseString(releaseString string) (uint32, error) {
if len(versionParts) >= 4 {
patch, _ = strconv.ParseUint(versionParts[3], 10, 8)
}

// clamp patch/sublevel to 255 EARLY in 4.14.252 because they merged this too early:
// https://github.com/torvalds/linux/commit/e131e0e880f942f138c4b5e6af944c7ddcd7ec96
if major == 4 && minor == 14 && patch >= 252 {
patch = 255
}

out := major*256*256 + minor*256 + patch
return uint32(out), nil
}
Expand Down
1 change: 1 addition & 0 deletions kernel_version_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ var testData = []struct {
{true, "4.1.", 262400},
{true, "4.1", 262400},
{true, "4.19-ovh", 267008},
{true, "4.14.252", kernelVersion: 265983},
}

func TestKernelVersionFromReleaseString(t *testing.T) {
Expand Down