[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 25/37] softmmu/physmem.c: Check return value from realpath()
From: |
Peter Maydell |
Subject: |
[PULL 25/37] softmmu/physmem.c: Check return value from realpath() |
Date: |
Thu, 26 Aug 2021 18:02:55 +0100 |
The realpath() function can return NULL on error, so we need to check
for it to avoid crashing when we try to strstr() into it.
This can happen if we run out of memory, or if /sys/ is not mounted,
among other situations.
Fixes: Coverity 1459913, 1460474
Fixes: ce317be98db0 ("exec: fetch the alignment of Linux devdax pmem character
device nodes")
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Jingqi Liu <jingqi.liu@intel.com>
Message-id: 20210812151525.31456-1-peter.maydell@linaro.org
---
softmmu/physmem.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/softmmu/physmem.c b/softmmu/physmem.c
index 31baf3a8877..23e77cb7715 100644
--- a/softmmu/physmem.c
+++ b/softmmu/physmem.c
@@ -1451,6 +1451,9 @@ static int64_t get_file_align(int fd)
path = g_strdup_printf("/sys/dev/char/%d:%d",
major(st.st_rdev), minor(st.st_rdev));
rpath = realpath(path, NULL);
+ if (!rpath) {
+ return -errno;
+ }
rc = daxctl_new(&ctx);
if (rc) {
--
2.20.1
- [PULL 22/37] stubs: Remove unused arch_type.c stub, (continued)
- [PULL 22/37] stubs: Remove unused arch_type.c stub, Peter Maydell, 2021/08/26
- [PULL 21/37] arch_init.h: Don't include arch_init.h unnecessarily, Peter Maydell, 2021/08/26
- [PULL 24/37] softmmu/physmem.c: Remove unneeded NULL check in qemu_ram_alloc_from_fd(), Peter Maydell, 2021/08/26
- [PULL 23/37] hw/core/loader: In gunzip(), check index is in range before use, not after, Peter Maydell, 2021/08/26
- [PULL 26/37] net: Zero sockaddr_in in parse_host_port(), Peter Maydell, 2021/08/26
- [PULL 30/37] raspi: Use error_fatal for SoC realize errors, not error_abort, Peter Maydell, 2021/08/26
- [PULL 28/37] tests/qtest/ipmi-bt-test: Zero-initialize sockaddr struct, Peter Maydell, 2021/08/26
- [PULL 32/37] hw/arm/virt: Delete EL3 error checksnow provided in CPU realize, Peter Maydell, 2021/08/26
- [PULL 27/37] gdbstub: Zero-initialize sockaddr structs, Peter Maydell, 2021/08/26
- [PULL 29/37] tests/tcg/multiarch/linux-test: Zero-initialize sockaddr structs, Peter Maydell, 2021/08/26
- [PULL 25/37] softmmu/physmem.c: Check return value from realpath(),
Peter Maydell <=
- [PULL 33/37] target/arm: Implement HSTR.TTEE, Peter Maydell, 2021/08/26
- [PULL 36/37] hw/arm/xlnx-versal: Add unimplemented APU mmio, Peter Maydell, 2021/08/26
- [PULL 35/37] target/arm: Do hflags rebuild in cpsr_write(), Peter Maydell, 2021/08/26
- [PULL 31/37] target/arm: Avoid assertion trying to use KVM and multiple ASes, Peter Maydell, 2021/08/26
- [PULL 37/37] hw/arm/xlnx-zynqmp: Add unimplemented APU mmio, Peter Maydell, 2021/08/26
- [PULL 34/37] target/arm: Implement HSTR.TJDBX, Peter Maydell, 2021/08/26
- Re: [PULL 00/37] target-arm queue, Peter Maydell, 2021/08/26