Commit 32f3bf67 authored by Thomas Gleixner's avatar Thomas Gleixner

x86/ioperm: Avoid bitmap allocation if no permissions are set

If ioperm() is invoked the first time and the @turn_on argument is 0, then
there is no point to allocate a bitmap just to clear permissions which are
not set.
Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
parent ae31cea8
...@@ -36,6 +36,9 @@ long ksys_ioperm(unsigned long from, unsigned long num, int turn_on) ...@@ -36,6 +36,9 @@ long ksys_ioperm(unsigned long from, unsigned long num, int turn_on)
*/ */
bitmap = t->io_bitmap_ptr; bitmap = t->io_bitmap_ptr;
if (!bitmap) { if (!bitmap) {
/* No point to allocate a bitmap just to clear permissions */
if (!turn_on)
return 0;
bitmap = kmalloc(IO_BITMAP_BYTES, GFP_KERNEL); bitmap = kmalloc(IO_BITMAP_BYTES, GFP_KERNEL);
if (!bitmap) if (!bitmap)
return -ENOMEM; return -ENOMEM;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment