x86/hvm: avoid potential NULL pointer dereferences
PATCH 1/1 x86/hvm: avoid potential NULL pointer dereferences
Coverity flagged that hvm_next_io_handler() will return NULL after calling domain_crash() and this will then lead to NULL pointer dereferences in calling functions.
This patch checks for NULL in the callers and bails in that case.
Signed-off-by Paul Durrant <[email protected]>
Cc Keir Fraser <[email protected]>
Cc Jan Beulich <[email protected]>
Cc Andrew Cooper <[email protected]>
--- xen/arch/x86/hvm/intercept.c | 6 ++++++ xen/arch/x86/hvm/io.c | 3 +++ xen/arch/x86/hvm/stdvga.c | 4 ++++ 3 files changed, 13 insertions(+)
xen/arch/x86/hvm/intercept.c +6 -0
@@ -265,6 +265,9 @@ void register_mmio_handler(struct domain *d, {struct hvm_io_handler *handler =hvm_next_io_handler (d); +if ( handler ==NULL ) +return ; + handler->type =IOREQ_TYPE_COPY ; handler->ops = &mmio_ops; handler->mmio.ops = ops;
@@ -275,6 +278,9 @@ void register_portio_handler(struct domain *d, unsigned int port, {struct hvm_io_handler *handler =hvm_next_io_handler (d); +if ( handler ==NULL ) +return ; + handler->type =IOREQ_TYPE_PIO ; handler->ops = &portio_ops; handler->portio.port = port;
xen/arch/x86/hvm/io.c +3 -0
@@ -255,6 +255,9 @@ void register_dpci_portio_handler(struct domain *d) {struct hvm_io_handler *handler =hvm_next_io_handler (d); +if ( handler ==NULL ) +return ; + handler->type =IOREQ_TYPE_PIO ; handler->ops = &dpci_portio_ops; }
xen/arch/x86/hvm/stdvga.c +4 -0
@@ -576,6 +576,10 @@ void stdvga_init(struct domain *d)/* VGA memory */ handler =hvm_next_io_handler (d); + +if ( handler ==NULL ) +return ; + handler->type =IOREQ_TYPE_COPY ; handler->ops = &stdvga_mem_ops; }
Signature · 1 line
1.7.10.4
Quoted 10 lines · Paul Durrant
Coverity flagged that
hvm_next_io_handler()will return NULL after callingdomain_crash()and this will then lead to NULL pointer dereferences in calling functions.This patch checks for NULL in the callers and bails in that case.
Signed-off-by Paul Durrant <[email protected]>Cc Keir Fraser <[email protected]>Cc Jan Beulich <[email protected]>Cc Andrew Cooper <[email protected]>
Reviewed-by Andrew Cooper <[email protected]>