init: Fix return logic in LoadKernelModules to handle first module failure
Problem:
The `LoadKernelModules` function did not correctly handle the failure of
the **first kernel module** (`bootprof.ko`). Instead of exiting immediately
when the first module failed, the function continued execution and returned
`true` by default. This behavior caused the system to proceed with subsequent
operations, resulting in unnecessary delays and ultimately a kernel panic.
Example log trace:
[ 0.467600][ T1] init: Loading module /lib/modules/bootprof.ko with args ''
[ 0.468648][ T1] bootprof: disagrees about version of symbol module_layout
[ 0.469663][ T1] init: Failed to insmod '/lib/modules/bootprof.ko' with args '': Exec format error
[ 0.470923][ T1] init: LoadWithAliases was unable to load bootprof
[ 10.558605][ T1] Kernel panic - not syncing: Attempted to kill init! exitcode=0x00007f00
Solution:
This commit modifies the `LoadKernelModules` function to consistently return
`retval`, which accurately reflects the status of the module loading operation.
If the **first module** fails to load, the function will now exit promptly with
the correct error status. This prevents unnecessary delays and avoids
proceeding with invalid assumptions.
Impact:
- Ensures that the system handles the failure of the **first kernel module**
appropriately by exiting early.
- Improves robustness during the initialization process.
- Prevents potential kernel panic caused by unhandled module load failures.
Assumptions:
- `retval` is correctly set to reflect the success or failure of the module
loading operation.
Test: treehugger
Flag: EXEMPT bugfix
Change-Id: If46e0b4787847530384660765334c315696c4d81
(cherry picked from commit 9cc51e4d63096350f05888c913f0ab89e06260af)
Loading
Please register or sign in to comment