On Wed, Nov 11, 2015 at 03:17:12PM +0200, Alberto Garcia wrote:
> @@ -583,32 +592,48 @@ static BlockBackend *blockdev_init(const char *file, 
> QDict *bs_opts,
>  
>          block_acct_init(blk_get_stats(blk), account_invalid, account_failed);
>  
> -        if (stats_intervals) {
> -            char **intervals = g_strsplit(stats_intervals, ":", 0);
> -            unsigned i;
> +        for (entry = qlist_first(interval_list); entry;
> +             entry = qlist_next(entry)) {

This loop could be extracted into a separate function to avoid growing 
blockdev_init() further:

bool parse_stats_intervals(BlockAcctStats *stats, QList *intervals, Error 
**errp);

> @@ -617,10 +642,14 @@ static BlockBackend *blockdev_init(const char *file, 
> QDict *bs_opts,
>  
>  err_no_bs_opts:
>      qemu_opts_del(opts);
> +    QDECREF(interval_dict);
> +    QDECREF(interval_list);
>      return blk;
>  
>  early_err:
>      qemu_opts_del(opts);
> +    QDECREF(interval_dict);
> +    QDECREF(interval_list);

There is a codepath that reaches here without initializing interval_dict
or interval_list:

  qemu_opts_absorb_qdict(opts, bs_opts, &error);
  if (error) {
      error_propagate(errp, error);
      goto early_err;
  }

interval_dict and interval_list should be initialized to NULL.

Attachment: signature.asc
Description: PGP signature

Reply via email to