[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>

authored by Ralph Wuerthner and committed by Martin Schwidefsky faa582ca fa331ffc

+7 -5
+7 -5
drivers/s390/crypto/ap_bus.c
··· 490 int rc; 491 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; 497 return rc; 498 } 499 ··· 534 535 ap_flush_queue(ap_dev); 536 del_timer_sync(&ap_dev->timeout); 537 - if (ap_drv->remove) 538 - ap_drv->remove(ap_dev); 539 spin_lock_bh(&ap_device_lock); 540 list_del_init(&ap_dev->list); 541 spin_unlock_bh(&ap_device_lock); 542 spin_lock_bh(&ap_dev->lock); 543 atomic_sub(ap_dev->queue_count, &ap_poll_requests); 544 spin_unlock_bh(&ap_dev->lock);
··· 490 int rc; 491 492 ap_dev->drv = ap_drv; 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 + } 499 return rc; 500 } 501 ··· 532 533 ap_flush_queue(ap_dev); 534 del_timer_sync(&ap_dev->timeout); 535 spin_lock_bh(&ap_device_lock); 536 list_del_init(&ap_dev->list); 537 spin_unlock_bh(&ap_device_lock); 538 + if (ap_drv->remove) 539 + ap_drv->remove(ap_dev); 540 spin_lock_bh(&ap_dev->lock); 541 atomic_sub(ap_dev->queue_count, &ap_poll_requests); 542 spin_unlock_bh(&ap_dev->lock);