diff mbox series

trace-cmd: free kbuf on malloc err in tracecmd_read_page_record()

Message ID 20200115200515.207711-1-marcgonzalez@google.com (mailing list archive)
State Accepted
Commit 26126a6607f6171202de9b9c4f09c80997e697be
Headers show
Series trace-cmd: free kbuf on malloc err in tracecmd_read_page_record() | expand

Commit Message

Marcelo Diop-Gonzalez Jan. 15, 2020, 8:05 p.m. UTC
This fixes an unlikely but possible leak

Signed-off-by: Marcelo Diop-Gonzalez <marcgonzalez@google.com>
---
 lib/trace-cmd/trace-input.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Steven Rostedt Jan. 21, 2020, 2:18 a.m. UTC | #1
On Wed, 15 Jan 2020 15:05:15 -0500
Marcelo Diop-Gonzalez <marcgonzalez@google.com> wrote:

> This fixes an unlikely but possible leak

Applied, thanks Marcelo!

-- Steve

> 
> Signed-off-by: Marcelo Diop-Gonzalez <marcgonzalez@google.com>
> ---
>  lib/trace-cmd/trace-input.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/lib/trace-cmd/trace-input.c b/lib/trace-cmd/trace-input.c
> index ac30a60..68da3a7 100644
> --- a/lib/trace-cmd/trace-input.c
> +++ b/lib/trace-cmd/trace-input.c
> @@ -1746,7 +1746,7 @@ tracecmd_read_page_record(struct tep_handle *pevent, void *page, int size,
>  
>  	record = malloc(sizeof(*record));
>  	if (!record)
> -		return NULL;
> +		goto out_free;
>  	memset(record, 0, sizeof(*record));
>  
>  	record->ts = ts;
diff mbox series

Patch

diff --git a/lib/trace-cmd/trace-input.c b/lib/trace-cmd/trace-input.c
index ac30a60..68da3a7 100644
--- a/lib/trace-cmd/trace-input.c
+++ b/lib/trace-cmd/trace-input.c
@@ -1746,7 +1746,7 @@  tracecmd_read_page_record(struct tep_handle *pevent, void *page, int size,
 
 	record = malloc(sizeof(*record));
 	if (!record)
-		return NULL;
+		goto out_free;
 	memset(record, 0, sizeof(*record));
 
 	record->ts = ts;