From 8f0ceba25143abe76b87f197525aac6a9f66485c Mon Sep 17 00:00:00 2001 From: Nicolas Dufresne Date: Wed, 8 Apr 2020 14:21:30 -0400 Subject: [PATCH] v4l2codecs: Fix FD leak during device enumeration This was revealed by Coverity. CID 1461248 --- sys/v4l2codecs/gstv4l2codecdevice.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/sys/v4l2codecs/gstv4l2codecdevice.c b/sys/v4l2codecs/gstv4l2codecdevice.c index 95bf717..eff61fa 100644 --- a/sys/v4l2codecs/gstv4l2codecdevice.c +++ b/sys/v4l2codecs/gstv4l2codecdevice.c @@ -26,6 +26,7 @@ #include #include #include +#include #define GST_CAT_DEFAULT gstv4l2codecs_debug GST_DEBUG_CATEGORY_EXTERN (gstv4l2codecs_debug); @@ -312,6 +313,7 @@ gst_v4l2_codec_find_devices (void) gint fd; struct media_v2_topology topology; GList *codec_entities, *c; + gboolean ret; fd = open (path, 0); if (fd < 0) @@ -319,7 +321,10 @@ gst_v4l2_codec_find_devices (void) GST_DEBUG ("Analysing media device '%s'", path); - if (!get_topology (fd, &topology)) { + ret = get_topology (fd, &topology); + close (fd); + + if (!ret) { clear_topology (&topology); continue; } -- 2.7.4