Skip to content

Commit

Permalink
Merge pull request #60 from DataDog/bryce.kahle/4-14-version-fix
Browse files Browse the repository at this point in the history
Fix kernel version sublevel on 4.14 branch
  • Loading branch information
brycekahle committed Nov 16, 2021
2 parents 3709b75 + fcae3c8 commit af58708
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
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

0 comments on commit af58708

Please sign in to comment.