Skip to content

Commit

Permalink
x86: fix dmi_alloc() to not advance alloc index in case of
Browse files Browse the repository at this point in the history
dmi_alloc() for CONFIG_X86_64 is defined to allocate from a static array
and it maintains a allocation index which is advanced each time allocation
is attempted - it gets incremented even if an allocation fails thereby
depriving any future request that may be small enough to be satisfied from
the array.

Fix this by first testing if allocation is going to be possible and
incrementing alloc index only then.

Signed-off-by: Parag Warudkar <parag.warudkar@gmail.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
  • Loading branch information
Parag Warudkar authored and Ingo Molnar committed Jan 30, 2008
1 parent 79da472 commit bca25ba
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion include/asm-x86/dmi.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,9 @@ extern char dmi_alloc_data[DMI_MAX_DATA];
static inline void *dmi_alloc(unsigned len)
{
int idx = dmi_alloc_index;
if ((dmi_alloc_index += len) > DMI_MAX_DATA)
if ((dmi_alloc_index + len) > DMI_MAX_DATA)
return NULL;
dmi_alloc_index += len;
return dmi_alloc_data + idx;
}

Expand Down

0 comments on commit bca25ba

Please sign in to comment.