Spi-hdlc-adapter: Check for invalid fd errors (#1129)

This commit makes a change to `spi-hdlc-adapter` to check for any
possible error case where either `sHdlcInputFd` or `sHdlcOutputFd`
are invalid (e.g., `dup()` failures) before starting the main loop.
This commit is contained in:
Abtin Keshavarzian
2017-01-11 09:09:54 -08:00
committed by Jonathan Hui
parent afa5d13cfc
commit 490eabb0e1
@@ -1540,6 +1540,12 @@ int main(int argc, char *argv[])
goto bail;
}
if ((sHdlcInputFd < 0) || (sHdlcOutputFd < 0))
{
sRet = EXIT_FAILURE;
goto bail;
}
// Set up sHdlcInputFd for non-blocking I/O
if (-1 == (i = fcntl(sHdlcInputFd, F_GETFL, 0)))
{