Skip to content

Commit

Permalink
[S390] zcrypt: fix ap_device_list handling
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Ralph Wuerthner authored and Martin Schwidefsky committed Mar 5, 2008
1 parent fa331ff commit faa582c
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions drivers/s390/crypto/ap_bus.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit faa582c

Please sign in to comment.