Linux Media Controller development
 help / color / mirror / Atom feed
From: Matthew Laux <matthew.laux@gmail.com>
To: linux-media@vger.kernel.org
Cc: Matthew Laux <matthew.laux@gmail.com>
Subject: [PATCH v4l-utils v2] media-info: ensure -1 is returned when a media device doesn't match
Date: Wed, 25 Nov 2026 16:07:02 -0600	[thread overview]
Message-ID: <20261125220702.26337-1-matthew.laux@gmail.com> (raw)

In the case of a non-match, mi_get_media_bus_info() would return the last
closed fd number. This led to the "Requests" tests running the "requests
are supported" path on a random fd and failing. Set the return value back
to -1 to prevent this. This only shows up when testing devices without a
media device, when other /dev/mediaN are present.

Fixes: 3b412f2890e7 ("v4l2-compliance: the -z/-u options failed to find the media device")
Signed-off-by: Matthew Laux <matthew.laux@gmail.com>
---
v2: corrected subject-prefix to "PATCH v4l-utils"

 utils/common/media-info.cpp | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/utils/common/media-info.cpp b/utils/common/media-info.cpp
index 6d6d7904..22eb897d 100644
--- a/utils/common/media-info.cpp
+++ b/utils/common/media-info.cpp
@@ -245,6 +245,7 @@ int mi_get_media_fd(int fd)
 
 			if (ioctl(media_fd, MEDIA_IOC_DEVICE_INFO, &mdinfo)) {
 				close(media_fd);
+				media_fd = -1;
 				continue;
 			}
 			break;
@@ -277,6 +278,7 @@ int mi_get_media_bus_info(const char *bus_info)
 			if (ioctl(media_fd, MEDIA_IOC_DEVICE_INFO, &mdinfo) ||
 			    strcmp(mdinfo.bus_info, bus_info)) {
 				close(media_fd);
+				media_fd = -1;
 				continue;
 			}
 			break;
-- 
2.47.3


                 reply	other threads:[~2026-11-25 22:07 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261125220702.26337-1-matthew.laux@gmail.com \
    --to=matthew.laux@gmail.com \
    --cc=linux-media@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox