Skip to contentSkip to conversation

xl/libxl: fixes for vsnd

PATCH In review Wei Liu 2 participants 5 messages Jul 10, 2018

lore
Share & tools
lore

Wei Liu

author
#0 lore raw

cover xl/libxl: fixes for vsnd

Wei Liu (3):
libxl/vsnd: add missing error checks xl/vsnd: use xcalloc to allocate memory for parser xl/vsnd: initialise rc in dryrun path

 tools/libxl/libxl_vsnd.c |  2 ++
 tools/xl/xl_parse.c      | 12 ++++++------
 tools/xl/xl_vsnd.c       |  1 +
 3 files changed, 9 insertions(+), 6 deletions(-)
Signature · 7 lines
2.11.0


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
author
#1 lore raw

PATCH 1/3 libxl/vsnd: add missing error checks

Reported-by Coverity
---
 tools/libxl/libxl_vsnd.c | 2 ++
 1 file changed, 2 insertions(+)
tools/libxl/libxl_vsnd.c +2 -0
index cf46e3ddb1..9570a4cf0e 100644
@@ -192,6 +192,7 @@ static int libxl__pcm_from_xenstore(libxl__gc *gc, const char *path,
                         GCSPRINTF("%s/"XENSND_FIELD_DEVICE_NAME, path), NULL);
 
     rc = libxl__params_from_xenstore(gc, path, &pcm->params);
+    if (rc) goto out;
 
     pcm->streams = NULL;
     pcm->num_vsnd_streams = 0;
@@ -253,6 +254,7 @@ static int libxl__vsnd_from_xenstore(libxl__gc *gc, const char *libxl_path,
                               fe_path), NULL);
 
     rc = libxl__params_from_xenstore(gc, fe_path, &vsnd->params);
+    if (rc) goto out;
 
     vsnd->pcms = NULL;
     vsnd->num_vsnd_pcms = 0;
Signature · 7 lines
2.11.0


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
author
#2 lore raw

PATCH 2/3 xl/vsnd: use xcalloc to allocate memory for parser

In reply to Wei Liu

... because it handles errors for us.

Reported-by Coverity
---
 tools/xl/xl_parse.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)
tools/xl/xl_parse.c +6 -6
index 3ebf6d9023..f9147f6a5c 100644
@@ -820,8 +820,8 @@ int parse_vdispl_config(libxl_device_vdispl *vdispl, char *token)
         split_string_into_string_list(oparg, ";", &connectors);
 
         vdispl->num_connectors = libxl_string_list_length(&connectors);
-        vdispl->connectors = calloc(vdispl->num_connectors,
-                                    sizeof(*vdispl->connectors));
+        vdispl->connectors = xcalloc(vdispl->num_connectors,
+                                     sizeof(*vdispl->connectors));
 
         for(i = 0; i < vdispl->num_connectors; i++)
         {
@@ -863,8 +863,8 @@ static int parse_vsnd_params(libxl_vsnd_params *params, char *token)
         split_string_into_string_list(oparg, ";", &rates);
 
         params->num_sample_rates = libxl_string_list_length(&rates);
-        params->sample_rates = calloc(params->num_sample_rates,
-                                      sizeof(*params->sample_rates));
+        params->sample_rates = xcalloc(params->num_sample_rates,
+                                       sizeof(*params->sample_rates));
 
         for (i = 0; i < params->num_sample_rates; i++) {
             params->sample_rates[i] = strtoul(rates[i], NULL, 0);
@@ -877,8 +877,8 @@ static int parse_vsnd_params(libxl_vsnd_params *params, char *token)
         split_string_into_string_list(oparg, ";", &formats);
 
         params->num_sample_formats = libxl_string_list_length(&formats);
-        params->sample_formats = calloc(params->num_sample_formats,
-                                        sizeof(*params->sample_formats));
+        params->sample_formats = xcalloc(params->num_sample_formats,
+                                         sizeof(*params->sample_formats));
 
         for (i = 0; i < params->num_sample_formats; i++) {
             libxl_vsnd_pcm_format format;
Signature · 7 lines
2.11.0


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
author
#3 lore raw

PATCH 3/3 xl/vsnd: initialise rc in dryrun path

In reply to Wei Liu
Reported-by Coverity
---
 tools/xl/xl_vsnd.c | 1 +
 1 file changed, 1 insertion(+)
tools/xl/xl_vsnd.c +1 -0
index 6dd3a901b2..3306b93139 100644
@@ -46,6 +46,7 @@ int main_vsndattach(int argc, char **argv)
     if (dryrun_only) {
         char *json = libxl_device_vsnd_to_json(ctx, &vsnd);
         printf("vsnd: %s\n", json);
+        rc = 0;
         free(json);
         goto out;
     }
Signature · 7 lines
2.11.0


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel