Re: [PATCH] sm501: Add uart support

Andrew Morton
2008-02-13T00:05:30Z

On Fri, 08 Feb 2008 18:57:42 +0900
Magnus Damm <magnus.damm@gmail.com> wrote:

> smdev = kzalloc(sizeof(struct sm501_device) +
> - sizeof(struct resource) * res_count, GFP_KERNEL);
> + (sizeof(struct resource) * res_count) +
> + platform_data_size, GFP_KERNEL);
>
> ...
>
> + smdev->pdev.resource = (struct resource *)(smdev+1);

So this driver plays party tricks with memory allocation and the C type
system.

We could at least add

struct resource resources[0];

to the end of `struct sm501_device' to avoid the type abuse. Or we could
even get radical and splurge four bytes on a `struct resource *'. But
please, not this.

Oh well. A pre-existing problem.