Skip to content

Commit 55449af

Browse files
committed
Merge tag 'hyperv-fixes-4.20-rc6' of git://git.kernel.org/pub/scm/linux/kernel/git/hyperv/linux into char-misc-linus
Sasha writes: hyperv-fixes-4.20-rc6 * tag 'hyperv-fixes-4.20-rc6' of git://git.kernel.org/pub/scm/linux/kernel/git/hyperv/linux: Drivers: hv: vmbus: Return -EINVAL for the sys files for unopened channels x86, hyperv: remove PCI dependency
2 parents cb4f131 + fc96df1 commit 55449af

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

drivers/hv/Kconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ menu "Microsoft Hyper-V guest support"
44

55
config HYPERV
66
tristate "Microsoft Hyper-V client drivers"
7-
depends on X86 && ACPI && PCI && X86_LOCAL_APIC && HYPERVISOR_GUEST
7+
depends on X86 && ACPI && X86_LOCAL_APIC && HYPERVISOR_GUEST
88
select PARAVIRT
99
help
1010
Select this option to run Linux as a Hyper-V client operating

drivers/hv/vmbus_drv.c

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -316,6 +316,8 @@ static ssize_t out_intr_mask_show(struct device *dev,
316316

317317
if (!hv_dev->channel)
318318
return -ENODEV;
319+
if (hv_dev->channel->state != CHANNEL_OPENED_STATE)
320+
return -EINVAL;
319321
hv_ringbuffer_get_debuginfo(&hv_dev->channel->outbound, &outbound);
320322
return sprintf(buf, "%d\n", outbound.current_interrupt_mask);
321323
}
@@ -329,6 +331,8 @@ static ssize_t out_read_index_show(struct device *dev,
329331

330332
if (!hv_dev->channel)
331333
return -ENODEV;
334+
if (hv_dev->channel->state != CHANNEL_OPENED_STATE)
335+
return -EINVAL;
332336
hv_ringbuffer_get_debuginfo(&hv_dev->channel->outbound, &outbound);
333337
return sprintf(buf, "%d\n", outbound.current_read_index);
334338
}
@@ -343,6 +347,8 @@ static ssize_t out_write_index_show(struct device *dev,
343347

344348
if (!hv_dev->channel)
345349
return -ENODEV;
350+
if (hv_dev->channel->state != CHANNEL_OPENED_STATE)
351+
return -EINVAL;
346352
hv_ringbuffer_get_debuginfo(&hv_dev->channel->outbound, &outbound);
347353
return sprintf(buf, "%d\n", outbound.current_write_index);
348354
}
@@ -357,6 +363,8 @@ static ssize_t out_read_bytes_avail_show(struct device *dev,
357363

358364
if (!hv_dev->channel)
359365
return -ENODEV;
366+
if (hv_dev->channel->state != CHANNEL_OPENED_STATE)
367+
return -EINVAL;
360368
hv_ringbuffer_get_debuginfo(&hv_dev->channel->outbound, &outbound);
361369
return sprintf(buf, "%d\n", outbound.bytes_avail_toread);
362370
}
@@ -371,6 +379,8 @@ static ssize_t out_write_bytes_avail_show(struct device *dev,
371379

372380
if (!hv_dev->channel)
373381
return -ENODEV;
382+
if (hv_dev->channel->state != CHANNEL_OPENED_STATE)
383+
return -EINVAL;
374384
hv_ringbuffer_get_debuginfo(&hv_dev->channel->outbound, &outbound);
375385
return sprintf(buf, "%d\n", outbound.bytes_avail_towrite);
376386
}
@@ -384,6 +394,8 @@ static ssize_t in_intr_mask_show(struct device *dev,
384394

385395
if (!hv_dev->channel)
386396
return -ENODEV;
397+
if (hv_dev->channel->state != CHANNEL_OPENED_STATE)
398+
return -EINVAL;
387399
hv_ringbuffer_get_debuginfo(&hv_dev->channel->inbound, &inbound);
388400
return sprintf(buf, "%d\n", inbound.current_interrupt_mask);
389401
}
@@ -397,6 +409,8 @@ static ssize_t in_read_index_show(struct device *dev,
397409

398410
if (!hv_dev->channel)
399411
return -ENODEV;
412+
if (hv_dev->channel->state != CHANNEL_OPENED_STATE)
413+
return -EINVAL;
400414
hv_ringbuffer_get_debuginfo(&hv_dev->channel->inbound, &inbound);
401415
return sprintf(buf, "%d\n", inbound.current_read_index);
402416
}
@@ -410,6 +424,8 @@ static ssize_t in_write_index_show(struct device *dev,
410424

411425
if (!hv_dev->channel)
412426
return -ENODEV;
427+
if (hv_dev->channel->state != CHANNEL_OPENED_STATE)
428+
return -EINVAL;
413429
hv_ringbuffer_get_debuginfo(&hv_dev->channel->inbound, &inbound);
414430
return sprintf(buf, "%d\n", inbound.current_write_index);
415431
}
@@ -424,6 +440,8 @@ static ssize_t in_read_bytes_avail_show(struct device *dev,
424440

425441
if (!hv_dev->channel)
426442
return -ENODEV;
443+
if (hv_dev->channel->state != CHANNEL_OPENED_STATE)
444+
return -EINVAL;
427445
hv_ringbuffer_get_debuginfo(&hv_dev->channel->inbound, &inbound);
428446
return sprintf(buf, "%d\n", inbound.bytes_avail_toread);
429447
}
@@ -438,6 +456,8 @@ static ssize_t in_write_bytes_avail_show(struct device *dev,
438456

439457
if (!hv_dev->channel)
440458
return -ENODEV;
459+
if (hv_dev->channel->state != CHANNEL_OPENED_STATE)
460+
return -EINVAL;
441461
hv_ringbuffer_get_debuginfo(&hv_dev->channel->inbound, &inbound);
442462
return sprintf(buf, "%d\n", inbound.bytes_avail_towrite);
443463
}

0 commit comments

Comments
 (0)