Commit cf1aeca
committed
u-boot: v2026.04: helios64: avoid unaligned 8-byte read on OTP serial_num
Per CodeRabbit review on PR armbian#9675:
*((uint64_t *) otp.serial_num) & 0xFFFFFFFFFFFF reads 8 bytes from a
6-byte field inside a __packed__ struct (over-reads into mfg_year),
and is unaligned. UB per the C standard, and would fault on stricter
alignment requirements.
Same pattern affects two call sites the bot pointed at (lines 103-104
and 217-218 of the original vendor file). The bot did not flag it but
*(u16 *) otp.mfg_year on the next line has the same problem - packed
field, unaligned access - so fix it together.
Replace the casts with two small inline helpers that decode the bytes
explicitly little-endian (RK3399 is LE, matches the vendor's original
intent):
otp_serial() - assemble 6 bytes into a u64
otp_mfg_year() - assemble 2 bytes into a u16
This is pre-existing Kobol vendor code carried forward through every
U-Boot bump; this PR migrates the board files to v2026.04, so it is
the right place to fix it.1 parent c015eb7 commit cf1aeca
1 file changed
Lines changed: 23 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
43 | 43 | | |
44 | 44 | | |
45 | 45 | | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
46 | 66 | | |
47 | 67 | | |
48 | 68 | | |
| |||
96 | 116 | | |
97 | 117 | | |
98 | 118 | | |
99 | | - | |
100 | | - | |
| 119 | + | |
101 | 120 | | |
102 | | - | |
| 121 | + | |
103 | 122 | | |
104 | 123 | | |
105 | 124 | | |
| |||
210 | 229 | | |
211 | 230 | | |
212 | 231 | | |
213 | | - | |
214 | | - | |
| 232 | + | |
215 | 233 | | |
216 | 234 | | |
217 | 235 | | |
| |||
0 commit comments