Re: [PATCH] btt: fix potential memory leak problem in io_free_all()

Jeff Moyer <[email protected]>
Newsgroups org.kernel.vger.linux-btrace
Message-ID <[email protected]>
songkai <[email protected]> writes:

> In “struct io” , the "void *pdu" member points to the memory
> which is allocated in convert_to_cpu(). We should free memory
> pdu point to before we free "struct io", or memory leak occurred.

That should be freed via io_release.  Do you know of a case where that
doesn't happen?  Also, io_free_all is only called right before exit.
I'm not sure this patch really plugs a leak that would impact normal
operations.

The patch seems harmless, but I'm not sure it's needed.

Cheers,
Jeff

>
> Signed-off-by: songkai <[email protected]>
> ---
>  btt/inlines.h | 3 +++
>  1 file changed, 3 insertions(+)
>
> diff --git a/btt/inlines.h b/btt/inlines.h
> index 64b5a2c..fa5a546 100644
> --- a/btt/inlines.h
> +++ b/btt/inlines.h
> @@ -153,6 +153,9 @@ static inline void io_free_all(void)
>  
>  	list_for_each_safe(p, q, &all_ios) {
>  		iop = list_entry(p, struct io, a_head);
> +
> +		if (iop->pdu)
> +			free(iop->pdu);
>  		free(iop);
>  	}
>  }
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.