[PATCH] kexec: use mmap instead of read for slurp_file()

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

 



On Wed, 14 Oct 2015 17:05:52 -0700
Geoff Levand <geoff at infradead.org> wrote:

[snip]

> >  		if (err < 0)
> >  > 	> 	> 	> die("Can not seek to the begin of file %s: %s\n",
> >  > 	> 	> 	> 	> 	> filename, strerror(errno));
> > +> 	> 	> buf = slurp_fd(fd, filename, size, &nread);
> >  > 	> } else {
> > -> 	> 	> size = stats.st_size;
> > +> 	> 	> size = nread = stats.st_size;
> > +> 	> 	> buf = mmap(NULL, size,
> 
> With this change the caller can't tell if buf was malloc'ed or mmaped.  The
> only safe thing it can do is to not call free() on the returned buf, this will
> lead to memory leakage for malloc'ed buffers.

I have read the code and have not found any free call. Therefore I assumed
that the kexec approach is to not free the buffer *explicitly* and leave to
the kernel to free it *automatically* at process exit.

@Simon: Was this assumption wrong?

Michael




[Index of Archives]     [LM Sensors]     [Linux Sound]     [ALSA Users]     [ALSA Devel]     [Linux Audio Users]     [Linux Media]     [Kernel]     [Gimp]     [Yosemite News]     [Linux Media]

  Powered by Linux