9elements / converged-security-suite

Converged Security Suite for Intel & AMD platform security features
https://www.9esec.io
BSD 3-Clause "New" or "Revised" License
59 stars 15 forks source link

Add missing close to MSR register open fd #264

Closed mimir-d closed 3 years ago

mimir-d commented 3 years ago

testing:

% go test   
PASS
ok      github.com/9elements/converged-security-suite/v2/pkg/registers  0.289sw
rihter007 commented 3 years ago

The linter is right, in this case we theoretically can get a panic.

Also may be it makes sense to put the whole content of the for to a separate function to avoid defer-ing in a loop. But this is a nitpicking. Feel free to ignore :)

I guess once can use inplace function for it:

for i := 0; i < runtime.NumCPU(); i++ { func() { ... defer msr.Close() ... }() }

mimir-d commented 3 years ago

i could've sworn i put that defer after the error check. fixing...