x86: fix alloc_mptable()
Fix the conditions when we stop updating the mptable due to running out of slots. [ Impact: fix memory corruption / non-working update_mptable boot parameter ] Signed-off-by: Yinghai Lu <yinghai@kernel.org> Cc: Andrew Morton <akpm@linux-foundation.org> Cc: Jesse Barnes <jbarnes@virtuousgeek.org> Cc: Len Brown <lenb@kernel.org> LKML-Reference: <4A01C3BB.1000609@kernel.org> Signed-off-by: Ingo Molnar <mingo@elte.hu>
This commit is contained in:
@@ -870,24 +870,17 @@ static
|
|||||||
inline void __init check_irq_src(struct mpc_intsrc *m, int *nr_m_spare) {}
|
inline void __init check_irq_src(struct mpc_intsrc *m, int *nr_m_spare) {}
|
||||||
#endif /* CONFIG_X86_IO_APIC */
|
#endif /* CONFIG_X86_IO_APIC */
|
||||||
|
|
||||||
static int check_slot(unsigned long mpc_new_phys, unsigned long mpc_new_length,
|
static int
|
||||||
int count)
|
check_slot(unsigned long mpc_new_phys, unsigned long mpc_new_length, int count)
|
||||||
{
|
{
|
||||||
if (!mpc_new_phys) {
|
int ret = 0;
|
||||||
pr_info("No spare slots, try to append...take your risk, "
|
|
||||||
"new mpc_length %x\n", count);
|
if (!mpc_new_phys || count <= mpc_new_length) {
|
||||||
} else {
|
WARN(1, "update_mptable: No spare slots (length: %x)\n", count);
|
||||||
if (count <= mpc_new_length)
|
return -1;
|
||||||
pr_info("No spare slots, try to append..., "
|
|
||||||
"new mpc_length %x\n", count);
|
|
||||||
else {
|
|
||||||
pr_err("mpc_new_length %lx is too small\n",
|
|
||||||
mpc_new_length);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int __init replace_intsrc_all(struct mpc_table *mpc,
|
static int __init replace_intsrc_all(struct mpc_table *mpc,
|
||||||
@@ -946,7 +939,7 @@ static int __init replace_intsrc_all(struct mpc_table *mpc,
|
|||||||
} else {
|
} else {
|
||||||
struct mpc_intsrc *m = (struct mpc_intsrc *)mpt;
|
struct mpc_intsrc *m = (struct mpc_intsrc *)mpt;
|
||||||
count += sizeof(struct mpc_intsrc);
|
count += sizeof(struct mpc_intsrc);
|
||||||
if (!check_slot(mpc_new_phys, mpc_new_length, count))
|
if (check_slot(mpc_new_phys, mpc_new_length, count) < 0)
|
||||||
goto out;
|
goto out;
|
||||||
assign_to_mpc_intsrc(&mp_irqs[i], m);
|
assign_to_mpc_intsrc(&mp_irqs[i], m);
|
||||||
mpc->length = count;
|
mpc->length = count;
|
||||||
|
Reference in New Issue
Block a user