[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 18/24] pci-assign: do not test path with access() bef
From: |
Michael Tokarev |
Subject: |
[Qemu-devel] [PULL 18/24] pci-assign: do not test path with access() before opening |
Date: |
Fri, 6 Nov 2015 15:43:55 +0300 |
From: Paolo Bonzini <address@hidden>
Using access() is a time-of-check/time-of-use race condition. It is
okay to use them to provide better error messages, but that is pretty
much it.
In this case we can get the same error from fopen(), so just use
strerror and errno there---which actually improves the error
message most of the time.
Signed-off-by: Paolo Bonzini <address@hidden>
Reviewed-by: Eric Blake <address@hidden>
Signed-off-by: Michael Tokarev <address@hidden>
---
hw/i386/pci-assign-load-rom.c | 6 +-----
1 file changed, 1 insertion(+), 5 deletions(-)
diff --git a/hw/i386/pci-assign-load-rom.c b/hw/i386/pci-assign-load-rom.c
index 34a3a7e..e40b586 100644
--- a/hw/i386/pci-assign-load-rom.c
+++ b/hw/i386/pci-assign-load-rom.c
@@ -45,14 +45,10 @@ void *pci_assign_dev_load_option_rom(PCIDevice *dev, struct
Object *owner,
return NULL;
}
- if (access(rom_file, F_OK)) {
- error_report("pci-assign: Insufficient privileges for %s", rom_file);
- return NULL;
- }
-
/* Write "1" to the ROM file to enable it */
fp = fopen(rom_file, "r+");
if (fp == NULL) {
+ error_report("pci-assign: Cannot open %s: %s", rom_file,
strerror(errno));
return NULL;
}
val = 1;
--
2.1.4
- [Qemu-devel] [PULL 03/24] hw/display/tcx: Remove superfluous OBJECT() typecasts, (continued)
- [Qemu-devel] [PULL 03/24] hw/display/tcx: Remove superfluous OBJECT() typecasts, Michael Tokarev, 2015/11/06
- [Qemu-devel] [PULL 13/24] ui: Use g_new() & friends where that makes obvious sense, Michael Tokarev, 2015/11/06
- [Qemu-devel] [PULL 24/24] tap-bsd: use user-specified tap device if it already exists, Michael Tokarev, 2015/11/06
- [Qemu-devel] [PULL 14/24] qxl: Use g_new() & friends where that makes obvious sense, Michael Tokarev, 2015/11/06
- [Qemu-devel] [PULL 19/24] ivshmem-server: fix possible OVERRUN, Michael Tokarev, 2015/11/06
- [Qemu-devel] [PULL 07/24] xen: fix invalid assertion, Michael Tokarev, 2015/11/06
- [Qemu-devel] [PULL 05/24] fix bad indentation in pcie_cap_slot_write_config(), Michael Tokarev, 2015/11/06
- [Qemu-devel] [PULL 12/24] bt: fix use of uninitialized variable seqlen, Michael Tokarev, 2015/11/06
- [Qemu-devel] [PULL 21/24] exec: avoid unnecessary cacheline bounce on ram_list.mru_block, Michael Tokarev, 2015/11/06
- [Qemu-devel] [PULL 22/24] taget-ppc: Fix read access to IBAT registers higher than IBAT3, Michael Tokarev, 2015/11/06
- [Qemu-devel] [PULL 18/24] pci-assign: do not test path with access() before opening,
Michael Tokarev <=
- Re: [Qemu-devel] [PULL 00/24] Trivial patches for 2015-11-06, Peter Maydell, 2015/11/06
- [Qemu-devel] [PULL 15/24] usb: Use g_new() & friends where that makes obvious sense, Michael Tokarev, 2015/11/06
- [Qemu-devel] [PULL 04/24] maint: Ignore ivshmem binaries, Michael Tokarev, 2015/11/06