summaryrefslogtreecommitdiffstats
path: root/drivers/s390
diff options
context:
space:
mode:
authorRalph Wuerthner <rwuerthn@de.ibm.com>2008-03-05 12:37:13 +0100
committerMartin Schwidefsky <schwidefsky@de.ibm.com>2008-03-05 12:37:19 +0100
commitfaa582ca8014d2e1ede5568a813fb0e5c3c078df (patch)
tree18e4a7a8a877d2d246f01234fbbb61324a36354f /drivers/s390
parent[S390] sclp_vt220: speed up console output for interactive work (diff)
downloadlinux-faa582ca8014d2e1ede5568a813fb0e5c3c078df.tar.xz
linux-faa582ca8014d2e1ede5568a813fb0e5c3c078df.zip
[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')
-rw-r--r--drivers/s390/crypto/ap_bus.c12
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)
int rc;
ap_dev->drv = ap_drv;
- spin_lock_bh(&ap_device_lock);
- list_add(&ap_dev->list, &ap_device_list);
- spin_unlock_bh(&ap_device_lock);
rc = ap_drv->probe ? ap_drv->probe(ap_dev) : -ENODEV;
+ if (!rc) {
+ spin_lock_bh(&ap_device_lock);
+ list_add(&ap_dev->list, &ap_device_list);
+ spin_unlock_bh(&ap_device_lock);
+ }
return rc;
}
@@ -532,11 +534,11 @@ static int ap_device_remove(struct device *dev)
ap_flush_queue(ap_dev);
del_timer_sync(&ap_dev->timeout);
- if (ap_drv->remove)
- ap_drv->remove(ap_dev);
spin_lock_bh(&ap_device_lock);
list_del_init(&ap_dev->list);
spin_unlock_bh(&ap_device_lock);
+ if (ap_drv->remove)
+ ap_drv->remove(ap_dev);
spin_lock_bh(&ap_dev->lock);
atomic_sub(ap_dev->queue_count, &ap_poll_requests);
spin_unlock_bh(&ap_dev->lock);