xen/gnttab: fix gnttab_acquire_resource()
authorJuergen Gross <jgross@suse.com>
Tue, 11 Oct 2022 13:01:22 +0000 (15:01 +0200)
committerJan Beulich <jbeulich@suse.com>
Tue, 11 Oct 2022 13:01:22 +0000 (15:01 +0200)
commitb9560762392c01b3ee84148c07be8017cb42dbc9
tree92c5ff2e2f85e06702b2d881177767f53b1b398d
parent49510071ee93905378e54664778760ed3908d447
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>
master commit: 52daa6a8483e4fbd6757c9d1b791e23931791608
master date: 2022-09-09 16:28:38 +0100
tools/tests/resource/test-resource.c
xen/common/grant_table.c