Commit fc27603
Fix undefined behavior in getCabledPortTranceivers for backplane ports
Summary:
getCabledPortTranceivers() was dereferencing the optional returned by getTranscieverIdx() without checking if it actually had a value. This worked fine when all cabled ports had transceivers, but breaks for xphy-backplane ports which have no transceiver at all.
When getTranscieverIdx() returns nullopt for these ports, dereferencing it is undefined behavior. Tt was reading garbage memory that happened to look like TransceiverID(1). This garbage ID got added to the set of "expected transceivers", causing HW tests to fail with errors like "Transceivers that should be programmed but are not: 1".
The fix simply checks has_value() before dereferencing and skips ports that don't have transceivers.
Reviewed By: shiva-menta
Differential Revision: D91055041
fbshipit-source-id: 07a58a872700b3495e9d468f91396b0da122d6cc1 parent e882c2a commit fc27603
1 file changed
+7
-2
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
247 | 247 | | |
248 | 248 | | |
249 | 249 | | |
250 | | - | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
251 | 253 | | |
252 | | - | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
253 | 258 | | |
254 | 259 | | |
255 | 260 | | |
| |||
0 commit comments