]> git.baikalelectronics.ru Git - kernel.git/commit
kbuild: fix Module.markers permission error under cygwin
authorCedric Hombourger <chombourger@gmail.com>
Sat, 25 Apr 2009 07:38:21 +0000 (09:38 +0200)
committerSam Ravnborg <sam@ravnborg.org>
Fri, 1 May 2009 08:54:03 +0000 (10:54 +0200)
commit818c4e8466159063909eef607150a4a56dbf0837
tree9ef6d2953c553538732e0e9a4f444957422e2b53
parentd334ff61eb0f559bee7b67527ef19e65de7cccbc
kbuild: fix Module.markers permission error under cygwin

While building the kernel, we end-up calling modpost with -K and -M
options for the same file (Modules.markers).  This is resulting in
modpost's main function calling read_markers() and then write_markers() on
the same file.

We then have read_markers() mmap'ing the file, and writer_markers()
opening that same file for writing.

The issue is that read_markers() exits without munmap'ing the file and is
as a matter holding a reference on Modules.markers.  When write_markers()
is opening that very same file for writing, we still have a reference on
it and cygwin (Windows?) is then making fopen() fail with EPERM.

Calling release_file() before exiting read_markers() clears that reference
(and memory leak) and fopen() then succeeds.

Tested on both cygwin (1.3.22) and Linux.  Also ran modpost within
valgrind on Linux to make sure that the munmap'ed file was not accessed
after read_markers()

Signed-off-by: Cedric Hombourger <chombourger@gmail.com>
Cc: <stable@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
scripts/mod/modpost.c