linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] s390: cmf: fix use-after-free in enable_cmf
@ 2020-11-20  7:48 Qinglang Miao
  2020-11-20  8:00 ` Cornelia Huck
  0 siblings, 1 reply; 2+ messages in thread
From: Qinglang Miao @ 2020-11-20  7:48 UTC (permalink / raw)
  To: Vineeth Vijayan, Peter Oberparleiter, Heiko Carstens,
	Vasily Gorbik, Christian Borntraeger
  Cc: linux-s390, linux-kernel, Qinglang Miao

kfree(cdev) is called in put_device in the error branch. So that
device_unlock(&cdev->dev) would raise a use-after-free bug. In fact,
there's no need to call device_unlock after put_device.

Fix it by adding simply return after put_device.

Fixes: a6ef15652d26 ("s390/cio: fix use after free in cmb processing")
Reported-by: Hulk Robot <hulkci@huawei.com>
Signed-off-by: Qinglang Miao <miaoqinglang@huawei.com>
---
 drivers/s390/cio/cmf.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/s390/cio/cmf.c b/drivers/s390/cio/cmf.c
index 72dd2471e..e95ca476f 100644
--- a/drivers/s390/cio/cmf.c
+++ b/drivers/s390/cio/cmf.c
@@ -1149,9 +1149,12 @@ int enable_cmf(struct ccw_device *cdev)
 		sysfs_remove_group(&cdev->dev.kobj, cmbops->attr_group);
 		cmbops->free(cdev);
 	}
+
 out:
-	if (ret)
+	if (ret) {
 		put_device(&cdev->dev);
+		return ret;
+	}
 out_unlock:
 	device_unlock(&cdev->dev);
 	return ret;
-- 
2.23.0


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-11-20  8:00 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-11-20  7:48 [PATCH] s390: cmf: fix use-after-free in enable_cmf Qinglang Miao
2020-11-20  8:00 ` Cornelia Huck

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).