Re: [PATCH] sm501: Add uart support

From: Andrew Morton
Date: Tue Feb 12 2008 - 19:05:31 EST


On Fri, 08 Feb 2008 18:57:42 +0900
Magnus Damm <magnus.damm@xxxxxxxxx> 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.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/