s390/zcrypt: Fixed possible race condition in zcrypt module handling
authorIngo Tuchscherer <ingo.tuchscherer@de.ibm.com>
Tue, 16 Sep 2014 12:37:25 +0000 (14:37 +0200)
committerMartin Schwidefsky <schwidefsky@de.ibm.com>
Thu, 25 Sep 2014 08:52:04 +0000 (10:52 +0200)
Signed-off-by: Ingo Tuchscherer <ingo.tuchscherer@de.ibm.com>
Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
drivers/s390/crypto/zcrypt_api.c

index 0e18c5dcd91f3bfe28954dbd49cc626517ee6238..08f1830cbfc4020e5901b9ae1f12fae518f29ac5 100644 (file)
@@ -343,10 +343,11 @@ struct zcrypt_ops *__ops_lookup(unsigned char *name, int variant)
                        break;
                }
        }
+       if (!found || !try_module_get(zops->owner))
+               zops = NULL;
+
        spin_unlock_bh(&zcrypt_ops_list_lock);
 
-       if (!found)
-               return NULL;
        return zops;
 }
 
@@ -359,8 +360,6 @@ struct zcrypt_ops *zcrypt_msgtype_request(unsigned char *name, int variant)
                request_module("%s", name);
                zops = __ops_lookup(name, variant);
        }
-       if ((!zops) || (!try_module_get(zops->owner)))
-               return NULL;
        return zops;
 }
 EXPORT_SYMBOL(zcrypt_msgtype_request);