]> xenbits.xensource.com Git - people/aperard/xen-unstable.git/commitdiff
tools/9pfsd: add missing va_end() in fill_data()
authorJuergen Gross <jgross@suse.com>
Thu, 22 Feb 2024 10:51:56 +0000 (11:51 +0100)
committerJan Beulich <jbeulich@suse.com>
Thu, 22 Feb 2024 10:51:56 +0000 (11:51 +0100)
In xen-9pfsd fill_data() va_end() needs to be called before returning.

Coverity Id CID 1592145

Fixes: bcec59cf7ff4 ("tools/xen-9pfsd: add 9pfs version request support")
Signed-off-by: Juergen Gross <jgross@suse.com>
Reviewed-by: Anthony PERARD <anthony.perard@citrix.com>
tools/9pfsd/io.c

index ebc41027131271785cb6daeeba792624a55d1a66..adb887c7d988c7d05db27dfe5291198ad9cf5b76 100644 (file)
@@ -445,7 +445,7 @@ static int fill_data(struct ring *ring, const char *fmt, ...)
             if ( !*f || array_sz )
                 fmt_err(fmt);
             if ( !chk_data(ring, data, sizeof(uint16_t)) )
-                return pars;
+                goto out;
             array_sz = get_unaligned((uint16_t *)data);
             data += sizeof(uint16_t);
             *(unsigned int *)par = array_sz;
@@ -455,10 +455,10 @@ static int fill_data(struct ring *ring, const char *fmt, ...)
 
         case 'b':
             if ( !chk_data(ring, data, sizeof(uint8_t)) )
-                return pars;
+                goto out;
             if ( !fill_data_elem(&par, array, &array_sz, sizeof(uint8_t),
                                  data) )
-                return pars;
+                goto out;
             data += sizeof(uint8_t);
             break;
 
@@ -466,48 +466,48 @@ static int fill_data(struct ring *ring, const char *fmt, ...)
             if ( array_sz )
                 fmt_err(fmt);
             if ( !chk_data(ring, data, sizeof(uint32_t)) )
-                return pars;
+                goto out;
             len = get_unaligned((uint32_t *)data);
             data += sizeof(uint32_t);
             *(unsigned int *)par = len;
             par = va_arg(ap, void *);
             if ( !chk_data(ring, data, len) )
-                return pars;
+                goto out;
             memcpy(par, data, len);
             data += len;
             break;
 
         case 'L':
             if ( !chk_data(ring, data, sizeof(uint64_t)) )
-                return pars;
+                goto out;
             if ( !fill_data_elem(&par, array, &array_sz, sizeof(uint64_t),
                                  data) )
-                return pars;
+                goto out;
             data += sizeof(uint64_t);
             break;
 
         case 'S':
             if ( !chk_data(ring, data, sizeof(uint16_t)) )
-                return pars;
+                goto out;
             len = get_unaligned((uint16_t *)data);
             data += sizeof(uint16_t);
             if ( !chk_data(ring, data, len) )
-                return pars;
+                goto out;
             str_off = add_string(ring, data, len);
             if ( str_off == ~0 )
-                return pars;
+                goto out;
             if ( !fill_data_elem(&par, array, &array_sz, sizeof(unsigned int),
                                  &str_off) )
-                return pars;
+                goto out;
             data += len;
             break;
 
         case 'U':
             if ( !chk_data(ring, data, sizeof(uint32_t)) )
-                return pars;
+                goto out;
             if ( !fill_data_elem(&par, array, &array_sz, sizeof(uint32_t),
                                  data) )
-                return pars;
+                goto out;
             data += sizeof(uint32_t);
             break;
 
@@ -520,6 +520,9 @@ static int fill_data(struct ring *ring, const char *fmt, ...)
         pars++;
     }
 
+ out:
+    va_end(ap);
+
     return pars;
 }