mirror of
https://github.com/hardkernel/linux.git
synced 2026-06-05 02:21:52 +09:00
Drivers: hv: vmbus: Return -EINVAL for the sys files for unopened channels
commitfc96df16a1upstream. Before98f4c65176, we returned zeros for unopened channels. With98f4c65176, we started to return random on-stack values. We'd better return -EINVAL instead. Fixes:98f4c65176("hv: move ringbuffer bus attributes to dev_groups") Cc: stable@vger.kernel.org Cc: K. Y. Srinivasan <kys@microsoft.com> Cc: Haiyang Zhang <haiyangz@microsoft.com> Cc: Stephen Hemminger <sthemmin@microsoft.com> Signed-off-by: Dexuan Cui <decui@microsoft.com> Signed-off-by: Sasha Levin <sashal@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
cc70f14956
commit
ff53cc3576
@@ -300,6 +300,8 @@ static ssize_t out_intr_mask_show(struct device *dev,
|
||||
|
||||
if (!hv_dev->channel)
|
||||
return -ENODEV;
|
||||
if (hv_dev->channel->state != CHANNEL_OPENED_STATE)
|
||||
return -EINVAL;
|
||||
hv_ringbuffer_get_debuginfo(&hv_dev->channel->outbound, &outbound);
|
||||
return sprintf(buf, "%d\n", outbound.current_interrupt_mask);
|
||||
}
|
||||
@@ -313,6 +315,8 @@ static ssize_t out_read_index_show(struct device *dev,
|
||||
|
||||
if (!hv_dev->channel)
|
||||
return -ENODEV;
|
||||
if (hv_dev->channel->state != CHANNEL_OPENED_STATE)
|
||||
return -EINVAL;
|
||||
hv_ringbuffer_get_debuginfo(&hv_dev->channel->outbound, &outbound);
|
||||
return sprintf(buf, "%d\n", outbound.current_read_index);
|
||||
}
|
||||
@@ -327,6 +331,8 @@ static ssize_t out_write_index_show(struct device *dev,
|
||||
|
||||
if (!hv_dev->channel)
|
||||
return -ENODEV;
|
||||
if (hv_dev->channel->state != CHANNEL_OPENED_STATE)
|
||||
return -EINVAL;
|
||||
hv_ringbuffer_get_debuginfo(&hv_dev->channel->outbound, &outbound);
|
||||
return sprintf(buf, "%d\n", outbound.current_write_index);
|
||||
}
|
||||
@@ -341,6 +347,8 @@ static ssize_t out_read_bytes_avail_show(struct device *dev,
|
||||
|
||||
if (!hv_dev->channel)
|
||||
return -ENODEV;
|
||||
if (hv_dev->channel->state != CHANNEL_OPENED_STATE)
|
||||
return -EINVAL;
|
||||
hv_ringbuffer_get_debuginfo(&hv_dev->channel->outbound, &outbound);
|
||||
return sprintf(buf, "%d\n", outbound.bytes_avail_toread);
|
||||
}
|
||||
@@ -355,6 +363,8 @@ static ssize_t out_write_bytes_avail_show(struct device *dev,
|
||||
|
||||
if (!hv_dev->channel)
|
||||
return -ENODEV;
|
||||
if (hv_dev->channel->state != CHANNEL_OPENED_STATE)
|
||||
return -EINVAL;
|
||||
hv_ringbuffer_get_debuginfo(&hv_dev->channel->outbound, &outbound);
|
||||
return sprintf(buf, "%d\n", outbound.bytes_avail_towrite);
|
||||
}
|
||||
@@ -368,6 +378,8 @@ static ssize_t in_intr_mask_show(struct device *dev,
|
||||
|
||||
if (!hv_dev->channel)
|
||||
return -ENODEV;
|
||||
if (hv_dev->channel->state != CHANNEL_OPENED_STATE)
|
||||
return -EINVAL;
|
||||
hv_ringbuffer_get_debuginfo(&hv_dev->channel->inbound, &inbound);
|
||||
return sprintf(buf, "%d\n", inbound.current_interrupt_mask);
|
||||
}
|
||||
@@ -381,6 +393,8 @@ static ssize_t in_read_index_show(struct device *dev,
|
||||
|
||||
if (!hv_dev->channel)
|
||||
return -ENODEV;
|
||||
if (hv_dev->channel->state != CHANNEL_OPENED_STATE)
|
||||
return -EINVAL;
|
||||
hv_ringbuffer_get_debuginfo(&hv_dev->channel->inbound, &inbound);
|
||||
return sprintf(buf, "%d\n", inbound.current_read_index);
|
||||
}
|
||||
@@ -394,6 +408,8 @@ static ssize_t in_write_index_show(struct device *dev,
|
||||
|
||||
if (!hv_dev->channel)
|
||||
return -ENODEV;
|
||||
if (hv_dev->channel->state != CHANNEL_OPENED_STATE)
|
||||
return -EINVAL;
|
||||
hv_ringbuffer_get_debuginfo(&hv_dev->channel->inbound, &inbound);
|
||||
return sprintf(buf, "%d\n", inbound.current_write_index);
|
||||
}
|
||||
@@ -408,6 +424,8 @@ static ssize_t in_read_bytes_avail_show(struct device *dev,
|
||||
|
||||
if (!hv_dev->channel)
|
||||
return -ENODEV;
|
||||
if (hv_dev->channel->state != CHANNEL_OPENED_STATE)
|
||||
return -EINVAL;
|
||||
hv_ringbuffer_get_debuginfo(&hv_dev->channel->inbound, &inbound);
|
||||
return sprintf(buf, "%d\n", inbound.bytes_avail_toread);
|
||||
}
|
||||
@@ -422,6 +440,8 @@ static ssize_t in_write_bytes_avail_show(struct device *dev,
|
||||
|
||||
if (!hv_dev->channel)
|
||||
return -ENODEV;
|
||||
if (hv_dev->channel->state != CHANNEL_OPENED_STATE)
|
||||
return -EINVAL;
|
||||
hv_ringbuffer_get_debuginfo(&hv_dev->channel->inbound, &inbound);
|
||||
return sprintf(buf, "%d\n", inbound.bytes_avail_towrite);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user