Skip to content

Commit b8611d3

Browse files
muhomorrthestinger
authored andcommitted
enable deny_new_usb2 during normal boot before loading USB port driver
If needed, deny_new_usb2 gets disabled at a later stage by the USB HAL.
1 parent a1afc5c commit b8611d3

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

init/first_stage_init.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -276,6 +276,13 @@ bool LoadKernelModules(BootMode boot_mode, bool want_console, bool want_parallel
276276
}
277277
}
278278

279+
if (disable_usb_port) {
280+
if (auto res = WriteFile("/proc/sys/kernel/deny_new_usb2", "1"); res.ok()) {
281+
LOG(INFO) << "wrote 1 to deny_new_usb2";
282+
} else {
283+
LOG(ERROR) << "write to deny_new_usb2 failed";
284+
}
285+
}
279286
Modprobe m({MODULE_BASE_DIR}, GetModuleLoadList(boot_mode, MODULE_BASE_DIR), true, disable_usb_port);
280287
bool retval = (want_parallel) ? m.LoadModulesParallel(std::thread::hardware_concurrency())
281288
: m.LoadListedModules(!want_console);

0 commit comments

Comments
 (0)