mirror of
https://github.com/edk2-porting/linux-next.git
synced 2024-12-27 06:34:11 +08:00
s390/cio: fix unlocked access of online member
Make sure that access to the online member of a ccw device is guarded by the ccwlock. Reported-by: Cornelia Huck <cornelia.huck@de.ibm.com> Reviewed-by: Peter Oberparleiter <oberpar@linux.vnet.ibm.com> Signed-off-by: Sebastian Ott <sebott@linux.vnet.ibm.com> Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
This commit is contained in:
parent
d7528862cf
commit
74bd0d859d
@ -333,9 +333,9 @@ int ccw_device_set_offline(struct ccw_device *cdev)
|
|||||||
if (ret != 0)
|
if (ret != 0)
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
cdev->online = 0;
|
|
||||||
spin_lock_irq(cdev->ccwlock);
|
spin_lock_irq(cdev->ccwlock);
|
||||||
sch = to_subchannel(cdev->dev.parent);
|
sch = to_subchannel(cdev->dev.parent);
|
||||||
|
cdev->online = 0;
|
||||||
/* Wait until a final state or DISCONNECTED is reached */
|
/* Wait until a final state or DISCONNECTED is reached */
|
||||||
while (!dev_fsm_final_state(cdev) &&
|
while (!dev_fsm_final_state(cdev) &&
|
||||||
cdev->private->state != DEV_STATE_DISCONNECTED) {
|
cdev->private->state != DEV_STATE_DISCONNECTED) {
|
||||||
@ -446,7 +446,10 @@ int ccw_device_set_online(struct ccw_device *cdev)
|
|||||||
ret = cdev->drv->set_online(cdev);
|
ret = cdev->drv->set_online(cdev);
|
||||||
if (ret)
|
if (ret)
|
||||||
goto rollback;
|
goto rollback;
|
||||||
|
|
||||||
|
spin_lock_irq(cdev->ccwlock);
|
||||||
cdev->online = 1;
|
cdev->online = 1;
|
||||||
|
spin_unlock_irq(cdev->ccwlock);
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
rollback:
|
rollback:
|
||||||
@ -1745,8 +1748,7 @@ ccw_device_probe (struct device *dev)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int ccw_device_remove(struct device *dev)
|
||||||
ccw_device_remove (struct device *dev)
|
|
||||||
{
|
{
|
||||||
struct ccw_device *cdev = to_ccwdev(dev);
|
struct ccw_device *cdev = to_ccwdev(dev);
|
||||||
struct ccw_driver *cdrv = cdev->drv;
|
struct ccw_driver *cdrv = cdev->drv;
|
||||||
@ -1754,9 +1756,10 @@ ccw_device_remove (struct device *dev)
|
|||||||
|
|
||||||
if (cdrv->remove)
|
if (cdrv->remove)
|
||||||
cdrv->remove(cdev);
|
cdrv->remove(cdev);
|
||||||
|
|
||||||
|
spin_lock_irq(cdev->ccwlock);
|
||||||
if (cdev->online) {
|
if (cdev->online) {
|
||||||
cdev->online = 0;
|
cdev->online = 0;
|
||||||
spin_lock_irq(cdev->ccwlock);
|
|
||||||
ret = ccw_device_offline(cdev);
|
ret = ccw_device_offline(cdev);
|
||||||
spin_unlock_irq(cdev->ccwlock);
|
spin_unlock_irq(cdev->ccwlock);
|
||||||
if (ret == 0)
|
if (ret == 0)
|
||||||
@ -1769,10 +1772,12 @@ ccw_device_remove (struct device *dev)
|
|||||||
cdev->private->dev_id.devno);
|
cdev->private->dev_id.devno);
|
||||||
/* Give up reference obtained in ccw_device_set_online(). */
|
/* Give up reference obtained in ccw_device_set_online(). */
|
||||||
put_device(&cdev->dev);
|
put_device(&cdev->dev);
|
||||||
|
spin_lock_irq(cdev->ccwlock);
|
||||||
}
|
}
|
||||||
ccw_device_set_timeout(cdev, 0);
|
ccw_device_set_timeout(cdev, 0);
|
||||||
cdev->drv = NULL;
|
cdev->drv = NULL;
|
||||||
cdev->private->int_class = IRQIO_CIO;
|
cdev->private->int_class = IRQIO_CIO;
|
||||||
|
spin_unlock_irq(cdev->ccwlock);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user