diff options
author | Ralph Wuerthner <rwuerthn@de.ibm.com> | 2008-03-05 06:37:13 -0500 |
---|---|---|
committer | Martin Schwidefsky <schwidefsky@de.ibm.com> | 2008-03-05 06:37:19 -0500 |
commit | faa582ca8014d2e1ede5568a813fb0e5c3c078df (patch) | |
tree | 18e4a7a8a877d2d246f01234fbbb61324a36354f /drivers/s390/crypto | |
parent | fa331ffc56fb8ead0811a89e4a582bbd5f29d714 (diff) |
[S390] zcrypt: fix ap_device_list handling
In ap_device_probe() we can add the new ap device to the internal
device list only if the device probe function successfully returns.
Otherwise we might end up with an invalid device in the internal ap
device list.
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/ap_bus.c | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/drivers/s390/crypto/ap_bus.c b/drivers/s390/crypto/ap_bus.c index d0c6fd3b1c19..7b0b81901297 100644 --- a/drivers/s390/crypto/ap_bus.c +++ b/drivers/s390/crypto/ap_bus.c | |||
@@ -490,10 +490,12 @@ static int ap_device_probe(struct device *dev) | |||
490 | int rc; | 490 | int rc; |
491 | 491 | ||
492 | ap_dev->drv = ap_drv; | 492 | ap_dev->drv = ap_drv; |
493 | spin_lock_bh(&ap_device_lock); | ||
494 | list_add(&ap_dev->list, &ap_device_list); | ||
495 | spin_unlock_bh(&ap_device_lock); | ||
496 | rc = ap_drv->probe ? ap_drv->probe(ap_dev) : -ENODEV; | 493 | rc = ap_drv->probe ? ap_drv->probe(ap_dev) : -ENODEV; |
494 | if (!rc) { | ||
495 | spin_lock_bh(&ap_device_lock); | ||
496 | list_add(&ap_dev->list, &ap_device_list); | ||
497 | spin_unlock_bh(&ap_device_lock); | ||
498 | } | ||
497 | return rc; | 499 | return rc; |
498 | } | 500 | } |
499 | 501 | ||
@@ -532,11 +534,11 @@ static int ap_device_remove(struct device *dev) | |||
532 | 534 | ||
533 | ap_flush_queue(ap_dev); | 535 | ap_flush_queue(ap_dev); |
534 | del_timer_sync(&ap_dev->timeout); | 536 | del_timer_sync(&ap_dev->timeout); |
535 | if (ap_drv->remove) | ||
536 | ap_drv->remove(ap_dev); | ||
537 | spin_lock_bh(&ap_device_lock); | 537 | spin_lock_bh(&ap_device_lock); |
538 | list_del_init(&ap_dev->list); | 538 | list_del_init(&ap_dev->list); |
539 | spin_unlock_bh(&ap_device_lock); | 539 | spin_unlock_bh(&ap_device_lock); |
540 | if (ap_drv->remove) | ||
541 | ap_drv->remove(ap_dev); | ||
540 | spin_lock_bh(&ap_dev->lock); | 542 | spin_lock_bh(&ap_dev->lock); |
541 | atomic_sub(ap_dev->queue_count, &ap_poll_requests); | 543 | atomic_sub(ap_dev->queue_count, &ap_poll_requests); |
542 | spin_unlock_bh(&ap_dev->lock); | 544 | spin_unlock_bh(&ap_dev->lock); |