Em Fri, Feb 27, 2015 at 06:21:25PM +0800, Yunlong Song escreveu:
> Sort the output according to ASCII character list (using strcmp), which
> supports both number sequence and alphabet sequence.

That is a great feature to have, thanks!

But you are not calling closedir() if zalloc fails, I am fixing that for
you this time, please check those kinds of things in the future.

- Arnaldo
> @@ -1100,11 +1108,21 @@ void print_tracepoint_events(const char *subsys_glob, 
> const char *event_glob,
>       struct dirent *sys_next, *evt_next, sys_dirent, evt_dirent;
>       char evt_path[MAXPATHLEN];
>       char dir_path[MAXPATHLEN];
> +     char **evt_list = NULL;
> +     unsigned int evt_i = 0, evt_num = 0;
> +     bool evt_num_known = false;
>  
> +restart:
>       sys_dir = opendir(tracing_events_path);
>       if (!sys_dir)
>               return;
>  
> +     if (evt_num_known) {
> +             evt_list = zalloc(sizeof(char *) * evt_num);
> +             if (!evt_list)
> +                     goto out_enomem;

Here, zalloc fails, goto out_enomem, closedir() not called.

> +out_free:
> +     evt_num = evt_i;
> +     for (evt_i = 0; evt_i < evt_num; evt_i++)
> +             zfree(&evt_list[evt_i]);
> +     zfree(&evt_list);
> +     return;
> +
> +out_enomem:
> +     printf("FATAL: not enough memory to print %s\n",
> +                     event_type_descriptors[PERF_TYPE_TRACEPOINT]);
> +     if (evt_list)
> +             goto out_free;
>  }
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Reply via email to