From: Andrew Cooper Subject: [PATCH] x86/mm: Fix possible increment of uninitialised variable Date: Mon, 9 Sep 2013 18:43:40 +0100 Message-ID: <1378748620-6925-1-git-send-email-andrew.cooper3@citrix.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Xen-devel Cc: Andrew Cooper , Keir Fraser , Jan Beulich , Tim Deegan List-Id: xen-devel@lists.xenproject.org Discovered by Coverity, CID 1056101 When taking the continue branch on the first iteration of the loop, gfn would indeed be uninitialised when incremented. However, as gfn is unconditionally constructed from i{1..4} before use in the loop body, having it incremented in the loop header is useless. Therefore, simply remove it. Signed-off-by: Andrew Cooper CC: Keir Fraser CC: Jan Beulich CC: Tim Deegan --- I have compile tested this but not functionally tested it. It is fairly obvious from the code that it was simply wrong in the first place. --- xen/arch/x86/mm/p2m-pt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xen/arch/x86/mm/p2m-pt.c b/xen/arch/x86/mm/p2m-pt.c index 302b621..a1d5650 100644 --- a/xen/arch/x86/mm/p2m-pt.c +++ b/xen/arch/x86/mm/p2m-pt.c @@ -691,7 +691,7 @@ static void p2m_change_type_global(struct p2m_domain *p2m, l1mfn = _mfn(l2e_get_pfn(l2e[i2])); l1e = map_domain_page(mfn_x(l1mfn)); - for ( i1 = 0; i1 < L1_PAGETABLE_ENTRIES; i1++, gfn++ ) + for ( i1 = 0; i1 < L1_PAGETABLE_ENTRIES; i1++ ) { flags = l1e_get_flags(l1e[i1]); if ( p2m_flags_to_type(flags) != ot ) -- 1.7.10.4