On Sat, Sep 1, 2012 at 1:14 PM, shiraz hashim <shiraz.linux.ker...@gmail.com> wrote: > Hi Roland, > > On Wed, Aug 22, 2012 at 7:19 PM, Roland Stigge <sti...@antcom.de> wrote: >> @@ -2016,6 +2030,8 @@ pl022_probe(struct amba_device *adev, co >> pl022->master_info = platform_info; >> pl022->adev = adev; >> pl022->vendor = id->data; >> + /* Point chipselects to allocated memory beyond the main struct */ >> + pl022->chipselects = (int *) pl022 + sizeof(struct pl022); > > This is going beyond memory allocated for chipselects > as it adds 4 * sizeof(struct pl022) bytes to pl022.
Yes that is why the allocation looks like this: + master = spi_alloc_master(dev, sizeof(struct pl022) + sizeof(int) * + platform_info->num_chipselect); > pl022->chipselects = (int *) &pl022[1]; > can be musch safer. I see absolutely no sematic difference between these two methods to reach the first position beyond the first struct. If we're gonna be debating this it's a safe sign that this is not a good design pattern at all, so then it is better to simply devm_kzalloc(sizeof(int) * platform_info->num_chipselect); separately. (But I'm happy with the patch as it is. And the other way too, since I'm not very picky.) Yours, Linus Walleij ------------------------------------------------------------------------------ Live Security Virtual Conference Exclusive live event will cover all the ways today's security and threat landscape has changed and how IT managers can respond. Discussions will include endpoint security, mobile security and the latest in malware threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ _______________________________________________ spi-devel-general mailing list spi-devel-general@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/spi-devel-general