* kern/dl.c (grub_dl_load_file): Close file immediately when
we are done using it.
This commit is contained in:
parent
6a4737e5d8
commit
1d7a72fd8c
2 changed files with 22 additions and 9 deletions
|
@ -49,6 +49,9 @@
|
||||||
* util/hostdisk.c (make_device_name): Do not make any assumptions
|
* util/hostdisk.c (make_device_name): Do not make any assumptions
|
||||||
about the length of drive names.
|
about the length of drive names.
|
||||||
|
|
||||||
|
* kern/dl.c (grub_dl_load_file): Close file immediately when
|
||||||
|
we are done using it.
|
||||||
|
|
||||||
2009-04-12 David S. Miller <davem@davemloft.net>
|
2009-04-12 David S. Miller <davem@davemloft.net>
|
||||||
|
|
||||||
* kern/misc.c (grub_ltoa): Fix cast when handling negative
|
* kern/misc.c (grub_ltoa): Fix cast when handling negative
|
||||||
|
|
28
kern/dl.c
28
kern/dl.c
|
@ -584,7 +584,7 @@ grub_dl_load_core (void *addr, grub_size_t size)
|
||||||
grub_dl_t
|
grub_dl_t
|
||||||
grub_dl_load_file (const char *filename)
|
grub_dl_load_file (const char *filename)
|
||||||
{
|
{
|
||||||
grub_file_t file;
|
grub_file_t file = NULL;
|
||||||
grub_ssize_t size;
|
grub_ssize_t size;
|
||||||
void *core = 0;
|
void *core = 0;
|
||||||
grub_dl_t mod = 0;
|
grub_dl_t mod = 0;
|
||||||
|
@ -596,21 +596,31 @@ grub_dl_load_file (const char *filename)
|
||||||
size = grub_file_size (file);
|
size = grub_file_size (file);
|
||||||
core = grub_malloc (size);
|
core = grub_malloc (size);
|
||||||
if (! core)
|
if (! core)
|
||||||
goto failed;
|
{
|
||||||
|
grub_file_close (file);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
if (grub_file_read (file, core, size) != (int) size)
|
if (grub_file_read (file, core, size) != (int) size)
|
||||||
goto failed;
|
{
|
||||||
|
grub_file_close (file);
|
||||||
|
grub_free (core);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* We must close this before we try to process dependencies.
|
||||||
|
Some disk backends do not handle gracefully multiple concurrent
|
||||||
|
opens of the same device. */
|
||||||
|
grub_file_close (file);
|
||||||
|
|
||||||
mod = grub_dl_load_core (core, size);
|
mod = grub_dl_load_core (core, size);
|
||||||
if (! mod)
|
if (! mod)
|
||||||
goto failed;
|
{
|
||||||
|
grub_free (core);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
mod->ref_count = 0;
|
mod->ref_count = 0;
|
||||||
|
|
||||||
failed:
|
|
||||||
grub_file_close (file);
|
|
||||||
grub_free (core);
|
|
||||||
|
|
||||||
return mod;
|
return mod;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue