]> www.infradead.org Git - users/dwmw2/linux.git/commitdiff
vmbus: don't return values for uninitalized channels
authorStephen Hemminger <stephen@networkplumber.org>
Mon, 20 Aug 2018 21:16:40 +0000 (21:16 +0000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 26 Sep 2018 06:39:30 +0000 (08:39 +0200)
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@microsoft.com>
Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Cc: <stable@vger.kernel.org> # 4.15
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/hv/vmbus_drv.c

index b10fe26c48917983951e443d83584cd49295853d..c9a466be77092474f999c95b6d772b0162072bed 100644 (file)
@@ -1178,6 +1178,9 @@ static ssize_t vmbus_chan_attr_show(struct kobject *kobj,
        if (!attribute->show)
                return -EIO;
 
+       if (chan->state != CHANNEL_OPENED_STATE)
+               return -EINVAL;
+
        return attribute->show(chan, buf);
 }