Skip to content

Commit

Permalink
iiod: iiod-serial: Handle error creating thread in start_serial_daemon
Browse files Browse the repository at this point in the history
If the thread fails to start, we must be able to clean up the resources
that were allocated for it.

Signed-off-by: Paul Cercueil <[email protected]>
  • Loading branch information
pcercuei committed Mar 4, 2022
1 parent 68d1d8a commit 0152a9a
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion iiod/serial.c
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,11 @@ int start_serial_daemon(struct iio_context *ctx, const char *uart_params,
IIO_DEBUG("Serving over UART on %s at %u bps, %u bits\n",
dev, uart_bps, uart_bits);

return thread_pool_add_thread(pool, serial_main, pdata, "iiod_serial_thd");
err = thread_pool_add_thread(pool, serial_main, pdata, "iiod_serial_thd");
if (err)
goto err_close_fd;

return 0;

err_close_fd:
close(fd);
Expand Down

0 comments on commit 0152a9a

Please sign in to comment.