s390/cio: fix use-after-free in ccw_device_destroy_console
authorQinglang Miao <miaoqinglang@huawei.com>
Tue, 1 Dec 2020 06:31:50 +0000 (14:31 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 30 Dec 2020 10:53:46 +0000 (11:53 +0100)
commit1b4f4a160b0cd5b6c35fd26c1e969c5326a2d86c
treef95a58a06c2b2ae844b8ee3623672c57d643b3a3
parent11b2118f4ddde9b09f23039f29bea81f11ec4117
s390/cio: fix use-after-free in ccw_device_destroy_console

[ Upstream commit 14d4c4fa46eeaa3922e8e1c4aa727eb0a1412804 ]

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 <hulkci@huawei.com>
Suggested-by: Cornelia Huck <cohuck@redhat.com>
Signed-off-by: Qinglang Miao <miaoqinglang@huawei.com>
Reviewed-by: Cornelia Huck <cohuck@redhat.com>
Reviewed-by: Vineeth Vijayan <vneethv@linux.ibm.com>
[vneethv@linux.ibm.com: Slight modification in the commit-message]
Signed-off-by: Vineeth Vijayan <vneethv@linux.ibm.com>
Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/s390/cio/device.c