[FOSS_TLK]security: tlk_driver: fix sys_munlock issue
Scott Long [Wed, 7 Jan 2015 05:08:25 +0000 (21:08 -0800)]
Only call sys_munlock if current->mm is non-null to avoid
race condition where mm cleanup happens before tlk_device_release
is invoked.

Change-Id: I0ec2f9ba5cdf4f380d79aea86bc11b67adbada51
Signed-off-by: Scott Long <scottl@nvidia.com>
Reviewed-on: http://git-master/r/755008
Reviewed-by: Automatic_Commit_Validation_User
Reviewed-by: Varun Wadekar <vwadekar@nvidia.com>
Tested-by: Varun Wadekar <vwadekar@nvidia.com>

security/tlk_driver/ote_comms.c

index f600061..ddeea51 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012-2014 NVIDIA Corporation. All rights reserved.
+ * Copyright (c) 2012-2015 NVIDIA Corporation. All rights reserved.
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -232,7 +232,7 @@ static void te_release_mem_buffer(struct te_shmem_desc *shmem_desc)
        }
        kfree(shmem_desc->pages);
 
-       if (shmem_desc->is_locked) {
+       if (shmem_desc->is_locked && current->mm) {
                status = sys_munlock((unsigned long)shmem_desc->buffer,
                                                        shmem_desc->size);
                if (status)