fru-device: Own the bus list copy to prevent crash
_i2cBuses was a reference to the caller's local bus list. This list is
gone as soon as the caller returns, but the retry runs almost 5s later
on a timer, so it ends up using memory that no longer exists and cause
fru-device crashes.
Fix this by changing the reference into an owned copy.
Tested:
Before:
sometimes fru-device will core-dumps within 15 loops ac cycle:
```
Jun 08 03:37:51 bmc systemd[1]: xyz.openbmc_project.FruDevice.service: Main process exited, code=dumped, status=11/SEGV
Jun 08 03:37:51 bmc systemd[1]: xyz.openbmc_project.FruDevice.service: Failed with result 'core-dump'.
Jun 08 03:37:51 bmc systemd[1]: xyz.openbmc_project.FruDevice.service: Consumed 1.551s CPU time.
Jun 08 03:37:56 bmc systemd[1]: xyz.openbmc_project.FruDevice.service: Scheduled restart job, restart counter is at 1.
```
After:
fru-device will not core-dumps within 235 loops ac cycle.
Google-Bug-Id: 518601929
Google-Bug-Id: 515874892
Change-Id: Iddd049ed4247be4abb9043c6af589cde6e80b581
Signed-off-by: Jeff Lin <jefflin2@quanta.corp-partner.google.com>
2 files changed