From: "Jan Beulich" Subject: [PATCH v2 4/5] IOMMU/x86: correct page_list_first() use Date: Mon, 02 Feb 2015 11:20:47 +0000 Message-ID: <54CF6B9F020000780005BDBD@mail.emea.novell.com> References: <54CF68DF020000780005BD6C@mail.emea.novell.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=__Part3104A79F.1__=" Return-path: Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1YIF3j-0004OP-Nk for xen-devel@lists.xenproject.org; Mon, 02 Feb 2015 11:20:51 +0000 In-Reply-To: <54CF68DF020000780005BD6C@mail.emea.novell.com> 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 , Tim Deegan List-Id: xen-devel@lists.xenproject.org This is a MIME message. If you are reading this text, you may want to consider changing to a mail reader or gateway that understands how to properly handle MIME multipart messages. --=__Part3104A79F.1__= Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Comparing its result against NULL is unsafe when page lists use normal list entries for linking together - page_list_empty() needs to be used instead. Signed-off-by: Jan Beulich --- a/xen/drivers/passthrough/x86/iommu.c +++ b/xen/drivers/passthrough/x86/iommu.c @@ -85,8 +85,9 @@ int arch_iommu_populate_page_table(struc * first few entries. */ page_list_move(&d->page_list, &d->arch.relmem_list); - while ( (page =3D page_list_first(&d->page_list)) !=3D NULL && - (page->count_info & (PGC_state|PGC_broken)) ) + while ( !page_list_empty(&d->page_list) && + (page =3D page_list_first(&d->page_list), + (page->count_info & (PGC_state|PGC_broken))) ) { page_list_del(page, &d->page_list); page_list_add_tail(page, &d->arch.relmem_list); --=__Part3104A79F.1__= Content-Type: text/plain; name="x86-IOMMU-page-list.patch" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="x86-IOMMU-page-list.patch" IOMMU/x86: correct page_list_first() use=0A=0AComparing its result against = NULL is unsafe when page lists use normal=0Alist entries for linking = together - page_list_empty() needs to be used=0Ainstead.=0A=0ASigned-off-by= : Jan Beulich =0A=0A--- a/xen/drivers/passthrough/x86/io= mmu.c=0A+++ b/xen/drivers/passthrough/x86/iommu.c=0A@@ -85,8 +85,9 @@ int = arch_iommu_populate_page_table(struc=0A * first few entries.=0A = */=0A page_list_move(&d->page_list, &d->arch.relmem_list);= =0A- while ( (page =3D page_list_first(&d->page_list)) !=3D NULL = &&=0A- (page->count_info & (PGC_state|PGC_broken)) )=0A+ = while ( !page_list_empty(&d->page_list) &&=0A+ (page = =3D page_list_first(&d->page_list),=0A+ (page->count_info = & (PGC_state|PGC_broken))) )=0A {=0A page_list_del(page= , &d->page_list);=0A page_list_add_tail(page, &d->arch.relmem_l= ist);=0A --=__Part3104A79F.1__= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Xen-devel mailing list Xen-devel@lists.xen.org http://lists.xen.org/xen-devel --=__Part3104A79F.1__=--