Skip to content

Commit

Permalink
x86/ioperm: Avoid bitmap allocation if no permissions are set
Browse files Browse the repository at this point in the history
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: Thomas Gleixner <tglx@linutronix.de>
  • Loading branch information
Thomas Gleixner committed Nov 16, 2019
1 parent ae31cea commit 32f3bf6
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions arch/x86/kernel/ioport.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ long ksys_ioperm(unsigned long from, unsigned long num, int turn_on)
*/
bitmap = t->io_bitmap_ptr;
if (!bitmap) {
/* No point to allocate a bitmap just to clear permissions */
if (!turn_on)
return 0;
bitmap = kmalloc(IO_BITMAP_BYTES, GFP_KERNEL);
if (!bitmap)
return -ENOMEM;
Expand Down

0 comments on commit 32f3bf6

Please sign in to comment.