Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753874AbcLKUQh (ORCPT ); Sun, 11 Dec 2016 15:16:37 -0500 Received: from avasout06.plus.net ([212.159.14.18]:50415 "EHLO avasout06.plus.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753620AbcLKUQf (ORCPT ); Sun, 11 Dec 2016 15:16:35 -0500 X-CM-Score: 0.00 X-CNFS-Analysis: v=2.2 cv=Xom4AhN9 c=1 sm=1 tr=0 a=o7Djd4SkmPXITDn8qH+ssQ==:117 a=o7Djd4SkmPXITDn8qH+ssQ==:17 a=kj9zAlcOel0A:10 a=n5n_aSjo0skA:10 a=beXlt2xKAAAA:8 a=pGLkceISAAAA:8 a=IqrtonyG9xMMMZ-goloA:9 a=C17cxp9IJhr5xb29:21 a=A3yQAkGUkEv5-MBc:21 a=CjuIK1q_8ugA:10 a=gcY2M4Ci8LIz02MwfSIM:22 a=6kGIvZw6iX1k4Y-7sg4_:22 Date: Sun, 11 Dec 2016 20:16:31 +0000 From: Nick Dyer To: Dmitry Torokhov Cc: Andrew Duggan , Chris Healy , Henrik Rydberg , Benjamin Tissoires , Linus Walleij , Bjorn Andersson , linux-input@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v9] Input: synaptics-rmi4 - add support for F34 V7 bootloader Message-ID: <20161211201631.GA5882@lava.h.shmanahar.org> References: <1481415506-5152-1-git-send-email-nick@shmanahar.org> <20161211080349.GB39300@dtor-ws> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20161211080349.GB39300@dtor-ws> User-Agent: Mutt/1.5.24 (2015-08-30) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1685 Lines: 59 On Sun, Dec 11, 2016 at 12:03:49AM -0800, Dmitry Torokhov wrote: > On Sun, Dec 11, 2016 at 12:18:26AM +0000, Nick Dyer wrote: > > +static void rmi_f34v7_parse_img_header_10_bl_container(struct f34_data *f34, > > + const u8 *image) > > +{ > > + int i; > > + int num_of_containers; > > + unsigned int addr; > > + unsigned int container_id; > > + unsigned int length; > > + const u8 *content; > > + struct container_descriptor *descriptor; > > + > > + BUG_ON(f34->v7.img.bootloader.size < 4); > > Killing the box because you got bad firmware is not very nice... > > > + > > + num_of_containers = (f34->v7.img.bootloader.size - 4) / 4; > > Wouldn't > > num_of_containes = f34->v7.img.bootloader.size / 4 - 1; > > give the same result but be less "suspicious". The variable is 'int' so > for size < 4 we'll get a negative and the loop won't execute. Neat! > > + > > + for (i = 1; i <= num_of_containers; i++) { > > + addr = get_unaligned_le32(f34->v7.img.bootloader.data + i*4); > > + descriptor = (struct container_descriptor *)(image + addr); > > This casts away constness, which is not nice. DOes it still work if you > apply the below on top? I've run it through a few flash cycles with no issues. Tested-by: Nick Dyer > Thanks! Thanks for your help with this. > > -- > Dmitry > > > Input: synaptics-rmi4 - misc f34v7 changes > > From: Dmitry Torokhov > > Signed-off-by: Dmitry Torokhov > --- > drivers/input/rmi4/rmi_f34.h | 6 ++-- > drivers/input/rmi4/rmi_f34v7.c | 64 ++++++++++++++++------------------------ > 2 files changed, 28 insertions(+), 42 deletions(-)