[PATCH 4.18 109/235] vmbus: dont return values for uninitalized channels
From: Greg Kroah-Hartman
Date: Mon Sep 24 2018 - 08:34:26 EST
4.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Stephen Hemminger <stephen@xxxxxxxxxxxxxxxxxx>
commit 6712cc9c22117a8af9f3df272b4a44fd2e4201cd upstream.
For unsupported device types, the vmbus channel ringbuffer is never
initialized, and therefore reading the sysfs files will return garbage
or cause a kernel OOPS.
Fixes: c2e5df616e1a ("vmbus: add per-channel sysfs info")
Signed-off-by: Stephen Hemminger <sthemmin@xxxxxxxxxxxxx>
Signed-off-by: K. Y. Srinivasan <kys@xxxxxxxxxxxxx>
Cc: <stable@xxxxxxxxxxxxxxx> # 4.15
Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx>
---
drivers/hv/vmbus_drv.c | 3 +++
1 file changed, 3 insertions(+)
--- a/drivers/hv/vmbus_drv.c
+++ b/drivers/hv/vmbus_drv.c
@@ -1178,6 +1178,9 @@ static ssize_t vmbus_chan_attr_show(stru
if (!attribute->show)
return -EIO;
+ if (chan->state != CHANNEL_OPENED_STATE)
+ return -EINVAL;
+
return attribute->show(chan, buf);
}