From: "Jan Beulich" Subject: Re: [PATCH] x86/hvm: Correct hvm_ioreq_server_alloc_rangesets() failure path Date: Wed, 04 Jun 2014 13:22:26 +0100 Message-ID: <538F2BA20200007800017BF3@mail.emea.novell.com> References: <1401879643-3555-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: In-Reply-To: <1401879643-3555-1-git-send-email-andrew.cooper3@citrix.com> Content-Disposition: inline List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Andrew Cooper Cc: Paul Durrant , Keir Fraser , Xen-devel List-Id: xen-devel@lists.xenproject.org >>> On 04.06.14 at 13:00, wrote: > Coverity-ID: 1220092 "Unsigned compare against 0" > Coverity-ID: 1220093 "Out-of-bounds read" > > Both of these are cased by the the while() loop in the fail path, which > results in an infinite loop and memory corruption from rangeset_destroy(). > > Move hvm_ioreq_server_free_rangesets() up and use it for cleanup on the > failure path. > > Signed-off-by: Andrew Cooper Since you and Paul appear to agree to fix it that way, it'll go in as is, but ... > @@ -861,24 +873,11 @@ static int hvm_ioreq_server_alloc_rangesets(struct hvm_ioreq_server *s, > return 0; > > fail: > - while ( --i >= 0 ) ... the one line equivalent fix would have been to use while ( i-- ). Jan