]> xenbits.xensource.com Git - xen.git/commit
xen/gnttab: fix gnttab_acquire_resource()
authorJuergen Gross <jgross@suse.com>
Fri, 9 Sep 2022 12:53:47 +0000 (14:53 +0200)
committerAndrew Cooper <andrew.cooper3@citrix.com>
Fri, 9 Sep 2022 15:28:38 +0000 (16:28 +0100)
commit52daa6a8483e4fbd6757c9d1b791e23931791608
tree020eb84c4646137cdee8fe63239fb19753e131c7
parent9066d877bf57a47b0f09741dac996ee1055d6407
xen/gnttab: fix gnttab_acquire_resource()

Commit 9dc46386d89d ("gnttab: work around "may be used uninitialized"
warning") was wrong, as vaddrs can legitimately be NULL in case
XENMEM_resource_grant_table_id_status was specified for a grant table
v1. This would result in crashes in debug builds due to
ASSERT_UNREACHABLE() triggering.

Check vaddrs only to be NULL in the rc == 0 case.

Expand the tests in tools/tests/resource to tickle this path, and verify that
using XENMEM_resource_grant_table_id_status on a v1 grant table fails.

Fixes: 9dc46386d89d ("gnttab: work around "may be used uninitialized" warning")
Signed-off-by: Juergen Gross <jgross@suse.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com> # xen
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
Release-acked-by: Henry Wang <Henry.Wang@arm.com>
tools/tests/resource/test-resource.c
xen/common/grant_table.c