From: Ian Campbell Subject: Re: [PATCH 4/8] device-tree: get_val cannot cope with cells > 2, add early_panic Date: Thu, 6 Dec 2012 13:00:43 +0000 Message-ID: <1354798843.17165.87.camel@zakaz.uk.xensource.com> References: <1354554611.2693.30.camel@zakaz.uk.xensource.com> <1354554631-17861-4-git-send-email-ian.campbell@citrix.com> <50C08BD1.50905@citrix.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <50C08BD1.50905@citrix.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: David Vrabel Cc: "xen-devel@lists.xen.org" List-Id: xen-devel@lists.xenproject.org On Thu, 2012-12-06 at 12:13 +0000, David Vrabel wrote: > On 03/12/12 17:10, Ian Campbell wrote: > > Signed-off-by: Ian Campbell > > --- > > v3: early_panic instead of BUG_ON > > v2: drop unrelated white space fixup > > --- > > xen/common/device_tree.c | 3 +++ > > 1 files changed, 3 insertions(+), 0 deletions(-) > > > > diff --git a/xen/common/device_tree.c b/xen/common/device_tree.c > > index 9eb316f..5a0a1a6 100644 > > --- a/xen/common/device_tree.c > > +++ b/xen/common/device_tree.c > > @@ -58,6 +58,9 @@ static void __init get_val(const u32 **cell, u32 cells, u64 *val) > > { > > *val = 0; > > > > + if ( cells > 2 ) > > + early_panic("dtb value contains > 2 cells\n"); > > + > > This seems like overkill to me. get_val() truncates the value down to > 64 bits which is fine as no valid physical address is more than 64 bits. If something does end up giving us a >2 cell number (for example a 4 cell thing with an unhelpful endianess) then we will silently end up doing something which is unlikely to be the right thing. Ian.