aboutsummaryrefslogtreecommitdiffstats
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
parentx86/ioperm: Simplify first ioperm() invocation logic (diff)
downloadlinux-dev-32f3bf67ee78332f2caec0984cb9d412cd0a3c23.tar.xz
linux-dev-32f3bf67ee78332f2caec0984cb9d412cd0a3c23.zip
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;