loader: make disable-device more rebust

Check the number of arguments and ensure that the passed-in device to
disable parses correctly.

Sponsored by:		Netflix
This commit is contained in:
Warner Losh
2025-09-28 11:58:31 -06:00
parent 55025f42f6
commit b7473a5d68
+9 -1
View File
@@ -235,9 +235,17 @@ cli["disable-device"] = function(...)
return
end
if #argv > 1 then
print("Too many arguments")
print("usage error: disable-device device")
return
end
d, u = string.match(argv[1], "(%w*%a)(%d+)")
if d ~= nil then
if d ~= nil and u ~= nil then
loader.setenv("hint." .. d .. "." .. u .. ".disabled", "1")
else
print("Cannot parse " .. argv[1] .." into driver and unit number.")
end
end