Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754671AbbGPLJG (ORCPT ); Thu, 16 Jul 2015 07:09:06 -0400 Received: from cantor2.suse.de ([195.135.220.15]:59145 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753529AbbGPLJE (ORCPT ); Thu, 16 Jul 2015 07:09:04 -0400 Date: Thu, 16 Jul 2015 13:09:00 +0200 From: Joerg Roedel To: Will Deacon Cc: Joerg Roedel , "grant.likely@linaro.org" , Rob Herring , "linux-arm-kernel@lists.infradead.org" , "iommu@lists.linux-foundation.org" , "linux-kernel@vger.kernel.org" , "devicetree@vger.kernel.org" Subject: Re: [PATCH 1/2] of: base: Allow more args than MAX_PHANDLE_ARGS if required Message-ID: <20150716110900.GA30130@suse.de> References: <1437035444-13867-1-git-send-email-joro@8bytes.org> <1437035444-13867-2-git-send-email-joro@8bytes.org> <20150716102325.GC26390@arm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20150716102325.GC26390@arm.com> User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1748 Lines: 47 Hi Will, On Thu, Jul 16, 2015 at 11:23:26AM +0100, Will Deacon wrote: > On Thu, Jul 16, 2015 at 09:30:43AM +0100, Joerg Roedel wrote: > > +struct of_phandle_args *of_alloc_phandle_args(int size) > > +{ > > + struct of_phandle_args *args; > > + int e = max(0, size - MAX_PHANDLE_ARGS); > > + > > + args = kzalloc(sizeof(struct of_phandle_args) + e * sizeof(uint32_t), > > + GFP_KERNEL); > > Should you also update args->args_count to reflect the extended array? The args_count member just tells us how many of the array elements are used and not how many there are. So it doesn't need to be updated here. > That said, extending the fixed-size array member like this feels a bit > fragile. Does GCC not complain about out-of-bounds accesses if you > statically address args->args[MAX_PHANDLE_ARGS]? Admittedly, I can't > think *why* this would be break (things like additional padding will be > harmless), but I'm not intimate with the C standard. Yeah, I agree, it is not the best possible solution. But this way I don't need to update all callers, and thus it works better with our development model. But I am open for suggestions on how to solve this problem better. In fact, my main motivation in sending this was to get the discussion about an upstreamable solution started :) Lets see what the device-tree maintainers have to say. > I guess the more worrying possibility is if somebody adds a new member to > the end of of_phandle_args. I should probably add a comment there. Joerg -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/