summaryrefslogtreecommitdiff
path: root/arch/x86/kernel/ioport.c
diff options
context:
space:
mode:
authorThomas Gleixner <tglx@linutronix.de>2019-11-12 19:56:19 +0100
committerThomas Gleixner <tglx@linutronix.de>2019-11-16 11:24:01 +0100
commit32f3bf67ee78332f2caec0984cb9d412cd0a3c23 (patch)
tree47bf912535016ecb14a1d2f14db0bb8e05256a6e /arch/x86/kernel/ioport.c
parentae31cea86ab31f3d2e15d6cc8710754ad7330c9e (diff)
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: Thomas Gleixner <tglx@linutronix.de>
Diffstat (limited to 'arch/x86/kernel/ioport.c')
-rw-r--r--arch/x86/kernel/ioport.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/arch/x86/kernel/ioport.c b/arch/x86/kernel/ioport.c
index ca6aa1e33c97..80fa36be2670 100644
--- a/arch/x86/kernel/ioport.c
+++ b/arch/x86/kernel/ioport.c
@@ -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;