Fixed knetbsd misbehaviour when no module is loaded

This commit is contained in:
Vladimir 'phcoder' Serbinenko 2010-01-16 12:55:52 +01:00
parent ae9eb98c7d
commit d92b0c01d4

View file

@ -922,23 +922,18 @@ grub_netbsd_add_modules (void)
struct netbsd_module *mod;
unsigned modcnt = 0;
struct grub_netbsd_btinfo_modules *mods;
grub_addr_t last_addr = 0;
unsigned i;
grub_err_t err;
for (mod = netbsd_mods; mod; mod = mod->next)
{
if (mod->mod.addr + mod->mod.size > last_addr)
last_addr = mod->mod.addr + mod->mod.size;
modcnt++;
}
modcnt++;
mods = grub_malloc (sizeof (*mods) + sizeof (mods->mods[0]) * modcnt);
if (!mods)
return grub_errno;
mods->num = modcnt;
mods->last_addr = last_addr;
mods->last_addr = kern_end;
for (mod = netbsd_mods, i = 0; mod; i++, mod = mod->next)
mods->mods[i] = mod->mod;