From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from a2nlsmtp01-03.prod.iad2.secureserver.net ([198.71.225.37]:46868 "EHLO a2nlsmtp01-03.prod.iad2.secureserver.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726119AbeHUAez (ORCPT ); Mon, 20 Aug 2018 20:34:55 -0400 From: kys@linuxonhyperv.com To: gregkh@linuxfoundation.org, linux-kernel@vger.kernel.org, devel@linuxdriverproject.org, olaf@aepfle.de, apw@canonical.com, jasowang@redhat.com, sthemmin@microsoft.com, Michael.H.Kelley@microsoft.com, vkuznets@redhat.com Cc: Stephen Hemminger , "K . Y . Srinivasan" , stable@vger.kernel.org Subject: [PATCH] vmbus: don't return values for uninitalized channels Date: Mon, 20 Aug 2018 21:16:40 +0000 Message-Id: <20180820211640.5837-1-kys@linuxonhyperv.com> Reply-To: kys@microsoft.com Sender: stable-owner@vger.kernel.org List-ID: From: Stephen Hemminger 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 Signed-off-by: K. Y. Srinivasan Cc: # 4.15 --- drivers/hv/vmbus_drv.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/hv/vmbus_drv.c b/drivers/hv/vmbus_drv.c index e6d8fdac6d8b..4bbc420d1213 100644 --- a/drivers/hv/vmbus_drv.c +++ b/drivers/hv/vmbus_drv.c @@ -1368,6 +1368,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); } -- 2.18.0