* [PATCH] softmmu/physmem.c: Remove unneeded NULL check in qemu_ram_alloc_from_fd()
@ 2021-08-12 15:06 Peter Maydell
2021-08-13 8:18 ` Liu, Jingqi
0 siblings, 1 reply; 2+ messages in thread
From: Peter Maydell @ 2021-08-12 15:06 UTC (permalink / raw)
To: qemu-devel; +Cc: Paolo Bonzini, Jingqi Liu
In the alignment check added to qemu_ram_alloc_from_fd() in commit
ce317be98db0dfdfa, the condition includes a check that 'mr' is not
NULL. This check is unnecessary because we can assume that the
caller always passes us a valid MemoryRegion, and indeed later in the
function we assume mr is not NULL when we pass it to file_ram_alloc()
as new_block->mr. Remove it.
Fixes: Coverity 1459867
Fixes: ce317be98d ("exec: fetch the alignment of Linux devdax pmem character device nodes")
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
---
softmmu/physmem.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/softmmu/physmem.c b/softmmu/physmem.c
index 3c1912a1a07..c47cb6da2e4 100644
--- a/softmmu/physmem.c
+++ b/softmmu/physmem.c
@@ -2075,7 +2075,7 @@ RAMBlock *qemu_ram_alloc_from_fd(ram_addr_t size, MemoryRegion *mr,
}
file_align = get_file_align(fd);
- if (file_align > 0 && mr && file_align > mr->align) {
+ if (file_align > 0 && file_align > mr->align) {
error_setg(errp, "backing store align 0x%" PRIx64
" is larger than 'align' option 0x%" PRIx64,
file_align, mr->align);
--
2.20.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] softmmu/physmem.c: Remove unneeded NULL check in qemu_ram_alloc_from_fd()
2021-08-12 15:06 [PATCH] softmmu/physmem.c: Remove unneeded NULL check in qemu_ram_alloc_from_fd() Peter Maydell
@ 2021-08-13 8:18 ` Liu, Jingqi
0 siblings, 0 replies; 2+ messages in thread
From: Liu, Jingqi @ 2021-08-13 8:18 UTC (permalink / raw)
To: Peter Maydell, qemu-devel; +Cc: Paolo Bonzini
On 8/12/2021 11:06 PM, Peter Maydell wrote:
> In the alignment check added to qemu_ram_alloc_from_fd() in commit
> ce317be98db0dfdfa, the condition includes a check that 'mr' is not
> NULL. This check is unnecessary because we can assume that the
> caller always passes us a valid MemoryRegion, and indeed later in the
> function we assume mr is not NULL when we pass it to file_ram_alloc()
> as new_block->mr. Remove it.
>
> Fixes: Coverity 1459867
> Fixes: ce317be98d ("exec: fetch the alignment of Linux devdax pmem character device nodes")
> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
> ---
> softmmu/physmem.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/softmmu/physmem.c b/softmmu/physmem.c
> index 3c1912a1a07..c47cb6da2e4 100644
> --- a/softmmu/physmem.c
> +++ b/softmmu/physmem.c
> @@ -2075,7 +2075,7 @@ RAMBlock *qemu_ram_alloc_from_fd(ram_addr_t size, MemoryRegion *mr,
> }
>
> file_align = get_file_align(fd);
> - if (file_align > 0 && mr && file_align > mr->align) {
> + if (file_align > 0 && file_align > mr->align) {
> error_setg(errp, "backing store align 0x%" PRIx64
> " is larger than 'align' option 0x%" PRIx64,
> file_align, mr->align);
>
'mr' is indeed not NULL in the current code.
Reviewed-by: Jingqi Liu <jingqi.liu@intel.com>
Thanks,
Jingqi
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2021-08-13 8:18 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-12 15:06 [PATCH] softmmu/physmem.c: Remove unneeded NULL check in qemu_ram_alloc_from_fd() Peter Maydell
2021-08-13 8:18 ` Liu, Jingqi
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.