xen/arm: add_to_physmap_one: Avoid to map mfn 0 if an error occurs

By default, the function add_to_physmap_one set mfn to 0. Some code paths that
result to an error, continue and the map the mfn 0 (valid on ARM) to the
slot given by the guest.

To fix the problem, return directly an error if sanity check has failed.

Signed-off-by: Julien Grall <julien.grall@linaro.org>
Acked-by: Tim Deegan <tim@xen.org>
Acked-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
This commit is contained in:
Julien Grall authored and Ian Campbell committed 2013-10-24 14:02:02 +01:00
1 parent 170fa99671
commit 55021ff9ab
1 file changed
+6
+6
View File
@@ -981,6 +981,8 @@ static int xenmem_add_to_physmap_one(
idx &= ~XENMAPIDX_grant_table_status;
if ( idx < nr_status_frames(d->grant_table) )
mfn = virt_to_mfn(d->grant_table->status[idx]);
else
return -EINVAL;
}
else
{
@@ -990,6 +992,8 @@ static int xenmem_add_to_physmap_one(
if ( idx < nr_grant_frames(d->grant_table) )
mfn = virt_to_mfn(d->grant_table->shared_raw[idx]);
else
return -EINVAL;
}
d->arch.grant_table_gpfn[idx] = gpfn;
@@ -999,6 +1003,8 @@ static int xenmem_add_to_physmap_one(
case XENMAPSPACE_shared_info:
if ( idx == 0 )
mfn = virt_to_mfn(d->shared_info);
else
return -EINVAL;
break;
case XENMAPSPACE_gmfn_foreign:
{
Reference in new issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.