]> asedeno.scripts.mit.edu Git - 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, 12 Sep 2018 07:31:00 +0000 (09:31 +0200)
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 b1b548a21f919b31f8e5d7f670352ee6f7d25f56..c71cc857b649ddc23f3289e23ec43e898901fa1a 100644 (file)
@@ -1291,6 +1291,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);
 }