x86/hvm/ioreq: fix two bugs in hvm_create_ioreq_server
authorWei Liu <wei.liu2@citrix.com>
Wed, 4 Apr 2018 11:03:14 +0000 (12:03 +0100)
committerWei Liu <wei.liu2@citrix.com>
Wed, 4 Apr 2018 11:44:52 +0000 (12:44 +0100)
commit90eff18cc5e16e0749605d88092ecfa4ab126c8f
treec39b52ecd0a76abec2afcc92e13eb9114b7221b4
parent913acc1aa019054742217926dea0827e7a9df02e
x86/hvm/ioreq: fix two bugs in hvm_create_ioreq_server

It is possible to call the error path with i pointing beyond the end
of the array.

There is another bug that if there is already a default ioreq server,
the code will actually sets the element to NULL, hence leaking memory.

Move setting NULL to where it is needed.

Coverity-ID: 1433777
Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Reviewed-by: Paul Durrant <paul.durrant@citrix.com>
Acked-by: Andrew Cooper <andrew.cooper3@citrix.com>
xen/arch/x86/hvm/ioreq.c