aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorQinglang Miao <[email protected]>2020-12-01 14:31:50 +0800
committerHeiko Carstens <[email protected]>2020-12-09 21:02:07 +0100
commit14d4c4fa46eeaa3922e8e1c4aa727eb0a1412804 (patch)
tree74c4e55967098490304b430d43d34ffc577eb47c
parent8cc0dcfdc1c0e0be107d0288f9c0cf1f4201be62 (diff)
s390/cio: fix use-after-free in ccw_device_destroy_console
Use of sch->dev reference after the put_device() call could trigger the use-after-free bugs. Fix this by simply adjusting the position of put_device. Fixes: 37db8985b211 ("s390/cio: add basic protected virtualization support") Reported-by: Hulk Robot <[email protected]> Suggested-by: Cornelia Huck <[email protected]> Signed-off-by: Qinglang Miao <[email protected]> Reviewed-by: Cornelia Huck <[email protected]> Reviewed-by: Vineeth Vijayan <[email protected]> [[email protected]: Slight modification in the commit-message] Signed-off-by: Vineeth Vijayan <[email protected]> Signed-off-by: Heiko Carstens <[email protected]>
-rw-r--r--drivers/s390/cio/device.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/drivers/s390/cio/device.c b/drivers/s390/cio/device.c
index 5fbc549786ab..e0005a4fc978 100644
--- a/drivers/s390/cio/device.c
+++ b/drivers/s390/cio/device.c
@@ -1645,10 +1645,10 @@ void __init ccw_device_destroy_console(struct ccw_device *cdev)
struct io_subchannel_private *io_priv = to_io_private(sch);
set_io_private(sch, NULL);
- put_device(&sch->dev);
- put_device(&cdev->dev);
dma_free_coherent(&sch->dev, sizeof(*io_priv->dma_area),
io_priv->dma_area, io_priv->dma_area_dma);
+ put_device(&sch->dev);
+ put_device(&cdev->dev);
kfree(io_priv);
}