mirror of
https://github.com/torvalds/linux.git
synced 2024-11-15 16:41:58 +00:00
perf tools: Avoid double free in read_event_file()
The temporary 'buf' buffer allocated in read_event_file() may be freed twice. Move the free() call to the common function exit point. Fixes the following coverity complaints: Error: USE_AFTER_FREE (CWE-825): tools/perf/util/trace-event-read.c:309: double_free: Calling "free" frees pointer "buf" which has already been freed. Signed-off-by: Sanskriti Sharma <sansharm@redhat.com> Reviewed-by: Jiri Olsa <jolsa@kernel.org> Cc: Joe Lawrence <joe.lawrence@redhat.com> Link: http://lkml.kernel.org/r/1538490554-8161-5-git-send-email-sansharm@redhat.com Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
This commit is contained in:
parent
9c8a182e5a
commit
470c8f7c88
@ -297,10 +297,8 @@ static int read_event_file(struct tep_handle *pevent, char *sys,
|
||||
}
|
||||
|
||||
ret = do_read(buf, size);
|
||||
if (ret < 0) {
|
||||
free(buf);
|
||||
if (ret < 0)
|
||||
goto out;
|
||||
}
|
||||
|
||||
ret = parse_event_file(pevent, buf, size, sys);
|
||||
if (ret < 0)
|
||||
|
Loading…
Reference in New Issue
Block a user