]> xenbits.xensource.com Git - xen.git/commit
fix locking in offline_page()
authorJan Beulich <jbeulich@suse.com>
Tue, 3 Dec 2013 11:40:57 +0000 (12:40 +0100)
committerJan Beulich <jbeulich@suse.com>
Tue, 3 Dec 2013 11:40:57 +0000 (12:40 +0100)
commitd4837a56da4a59259dd0cf9f3bdc073159d81d7a
treeef415f51cb52a95e49c178a4a9b4c435ca44d6ed
parent51ad90aea21c7f5edff71620fe5d2b6543c42cba
fix locking in offline_page()

Coverity ID 1055655

Apart from the Coverity-detected lock order reversal (a domain's
page_alloc_lock taken with the heap lock already held), calling
put_page() with heap_lock is a bad idea too (as a possible descendant
from put_page() is free_heap_pages(), which wants to take this very
lock).

From all I can tell the region over which heap_lock was held was far
too large: All we need to protect are the call to mark_page_offline()
and reserve_heap_page() (and I'd even put under question the need for
the former). Hence by slightly re-arranging the if/else-if chain we
can drop the lock much earlier, at once no longer covering the two
put_page() invocations.

Once at it, do a little bit of other cleanup: Put the "pod_replace"
code path inline rather than at its own label, and drop the effectively
unused variable "ret".

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Tim Deegan <tim@xen.org>
Acked-by: Keir Fraser <keir@xen.org>
xen/common/page_alloc.c