Skip to content

Commit 0152a9a

Browse files
committed
iiod: iiod-serial: Handle error creating thread in start_serial_daemon
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]>
1 parent 68d1d8a commit 0152a9a

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

iiod/serial.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,11 @@ int start_serial_daemon(struct iio_context *ctx, const char *uart_params,
258258
IIO_DEBUG("Serving over UART on %s at %u bps, %u bits\n",
259259
dev, uart_bps, uart_bits);
260260

261-
return thread_pool_add_thread(pool, serial_main, pdata, "iiod_serial_thd");
261+
err = thread_pool_add_thread(pool, serial_main, pdata, "iiod_serial_thd");
262+
if (err)
263+
goto err_close_fd;
264+
265+
return 0;
262266

263267
err_close_fd:
264268
close(fd);

0 commit comments

Comments
 (0)