diff options
author | Ralph Wuerthner <rwuerthn@de.ibm.com> | 2007-03-19 08:19:19 -0400 |
---|---|---|
committer | Martin Schwidefsky <schwidefsky@de.ibm.com> | 2007-03-19 08:19:19 -0400 |
commit | 43a867a2d2a119c744bab6dc8d3e1da6809d7141 (patch) | |
tree | 156175709a93e36bdec9a0dbb91f3fa219816c76 /drivers/s390/crypto | |
parent | cf352ce0b9104dc6a1c11df52db9f910f1f6cd2e (diff) |
[S390] zcrypt: fix possible race when unloading zcrypt driver modules
Move try_module_get() call into spin protected block to prevent zcrypt
driver module unload while submitting a request to driver.
Signed-off-by: Ralph Wuerthner <rwuerthn@de.ibm.com>
Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
Diffstat (limited to 'drivers/s390/crypto')
-rw-r--r-- | drivers/s390/crypto/zcrypt_api.c | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/drivers/s390/crypto/zcrypt_api.c b/drivers/s390/crypto/zcrypt_api.c index 99761391f340..e3625a47a596 100644 --- a/drivers/s390/crypto/zcrypt_api.c +++ b/drivers/s390/crypto/zcrypt_api.c | |||
@@ -298,14 +298,14 @@ static long zcrypt_rsa_modexpo(struct ica_rsa_modexpo *mex) | |||
298 | get_device(&zdev->ap_dev->device); | 298 | get_device(&zdev->ap_dev->device); |
299 | zdev->request_count++; | 299 | zdev->request_count++; |
300 | __zcrypt_decrease_preference(zdev); | 300 | __zcrypt_decrease_preference(zdev); |
301 | spin_unlock_bh(&zcrypt_device_lock); | ||
302 | if (try_module_get(zdev->ap_dev->drv->driver.owner)) { | 301 | if (try_module_get(zdev->ap_dev->drv->driver.owner)) { |
302 | spin_unlock_bh(&zcrypt_device_lock); | ||
303 | rc = zdev->ops->rsa_modexpo(zdev, mex); | 303 | rc = zdev->ops->rsa_modexpo(zdev, mex); |
304 | spin_lock_bh(&zcrypt_device_lock); | ||
304 | module_put(zdev->ap_dev->drv->driver.owner); | 305 | module_put(zdev->ap_dev->drv->driver.owner); |
305 | } | 306 | } |
306 | else | 307 | else |
307 | rc = -EAGAIN; | 308 | rc = -EAGAIN; |
308 | spin_lock_bh(&zcrypt_device_lock); | ||
309 | zdev->request_count--; | 309 | zdev->request_count--; |
310 | __zcrypt_increase_preference(zdev); | 310 | __zcrypt_increase_preference(zdev); |
311 | put_device(&zdev->ap_dev->device); | 311 | put_device(&zdev->ap_dev->device); |
@@ -373,14 +373,14 @@ static long zcrypt_rsa_crt(struct ica_rsa_modexpo_crt *crt) | |||
373 | get_device(&zdev->ap_dev->device); | 373 | get_device(&zdev->ap_dev->device); |
374 | zdev->request_count++; | 374 | zdev->request_count++; |
375 | __zcrypt_decrease_preference(zdev); | 375 | __zcrypt_decrease_preference(zdev); |
376 | spin_unlock_bh(&zcrypt_device_lock); | ||
377 | if (try_module_get(zdev->ap_dev->drv->driver.owner)) { | 376 | if (try_module_get(zdev->ap_dev->drv->driver.owner)) { |
377 | spin_unlock_bh(&zcrypt_device_lock); | ||
378 | rc = zdev->ops->rsa_modexpo_crt(zdev, crt); | 378 | rc = zdev->ops->rsa_modexpo_crt(zdev, crt); |
379 | spin_lock_bh(&zcrypt_device_lock); | ||
379 | module_put(zdev->ap_dev->drv->driver.owner); | 380 | module_put(zdev->ap_dev->drv->driver.owner); |
380 | } | 381 | } |
381 | else | 382 | else |
382 | rc = -EAGAIN; | 383 | rc = -EAGAIN; |
383 | spin_lock_bh(&zcrypt_device_lock); | ||
384 | zdev->request_count--; | 384 | zdev->request_count--; |
385 | __zcrypt_increase_preference(zdev); | 385 | __zcrypt_increase_preference(zdev); |
386 | put_device(&zdev->ap_dev->device); | 386 | put_device(&zdev->ap_dev->device); |
@@ -408,14 +408,14 @@ static long zcrypt_send_cprb(struct ica_xcRB *xcRB) | |||
408 | get_device(&zdev->ap_dev->device); | 408 | get_device(&zdev->ap_dev->device); |
409 | zdev->request_count++; | 409 | zdev->request_count++; |
410 | __zcrypt_decrease_preference(zdev); | 410 | __zcrypt_decrease_preference(zdev); |
411 | spin_unlock_bh(&zcrypt_device_lock); | ||
412 | if (try_module_get(zdev->ap_dev->drv->driver.owner)) { | 411 | if (try_module_get(zdev->ap_dev->drv->driver.owner)) { |
412 | spin_unlock_bh(&zcrypt_device_lock); | ||
413 | rc = zdev->ops->send_cprb(zdev, xcRB); | 413 | rc = zdev->ops->send_cprb(zdev, xcRB); |
414 | spin_lock_bh(&zcrypt_device_lock); | ||
414 | module_put(zdev->ap_dev->drv->driver.owner); | 415 | module_put(zdev->ap_dev->drv->driver.owner); |
415 | } | 416 | } |
416 | else | 417 | else |
417 | rc = -EAGAIN; | 418 | rc = -EAGAIN; |
418 | spin_lock_bh(&zcrypt_device_lock); | ||
419 | zdev->request_count--; | 419 | zdev->request_count--; |
420 | __zcrypt_increase_preference(zdev); | 420 | __zcrypt_increase_preference(zdev); |
421 | put_device(&zdev->ap_dev->device); | 421 | put_device(&zdev->ap_dev->device); |