From 1c18e8aa69e473ab7ceb3a1ff0317e95489d7eb9 Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Thu, 16 Mar 2023 12:28:29 +0100 Subject: [PATCH] handle some error cases --- pipewire-v4l2/src/pipewire-v4l2.c | 6 ++++-- src/tools/pw-top.c | 3 ++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/pipewire-v4l2/src/pipewire-v4l2.c b/pipewire-v4l2/src/pipewire-v4l2.c index e58125f69..972f12428 100644 --- a/pipewire-v4l2/src/pipewire-v4l2.c +++ b/pipewire-v4l2/src/pipewire-v4l2.c @@ -800,8 +800,10 @@ static int v4l2_openat(int dirfd, const char *path, int oflag, mode_t mode) if ((file = find_file_by_dev(dev_id)) != NULL) { res = do_dup(file->fd, 0); unref_file(file); - if (res >= 0) - fcntl(res, F_SETFL, oflag); + if (res < 0) + return res; + if (fcntl(res, F_SETFL, oflag) < 0) + pw_log_warn("fd:%d failed to set flags: %m", res); return res; } diff --git a/src/tools/pw-top.c b/src/tools/pw-top.c index f7ad81012..972dd1fd7 100644 --- a/src/tools/pw-top.c +++ b/src/tools/pw-top.c @@ -171,7 +171,8 @@ static void node_param(void *data, int seq, { uint32_t media_type, media_subtype; - spa_format_parse(param, &media_type, &media_subtype); + if (spa_format_parse(param, &media_type, &media_subtype) < 0) + goto done; switch(media_type) { case SPA_MEDIA_TYPE_audio: