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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Jeff,
 
> songkai <songkai01@xxxxxxxxxx> 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.

Thank you for your reminding. So far, I can't find a case either.
Freeing pdu in io_release seems like enough. My original intention is that, 
when calling io_free_all before btt exits, there are still  some IOs in the all_ios, 
I am not sure if all the pdu is freed before, just like dip and pip. 

Thanks again. 

Regards,
songkai
 

> > Signed-off-by: songkai <songkai01@xxxxxxxxxx>
> > ---
> >  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);
> >  	}
> >  }





[Index of Archives]     [Netdev]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux