Re: [PATCH 1/1] drivers: brcmaxi: provide amba axi functionalityin separate module

From: Jiri Slaby
Date: Tue Mar 29 2011 - 06:45:53 EST


On 03/29/2011 11:40 AM, Arend van Spriel wrote:
> --- /dev/null
> +++ b/drivers/brcmaxi/axi.c
> @@ -0,0 +1,786 @@
...
> +/* resetctrl */
> +#define AIRC_RESET 1
> +
> +/* definition for specifying padding fields */
> +#define _PADLINE(line) pad ## line
> +#define _XSTR(line) _PADLINE(line)
> +#define PAD _XSTR(__LINE__)
> +
> +/*
> + * struct aidmp - device management plugin "wrapper" registers.
> + */
> +struct aidmp {

This looks like it should be __packed__.

> + u32 oobselina30; /* 0x000 */
> + u32 oobselina74; /* 0x004 */
> + u32 PAD[6];
...
> +};
...
> +struct axi_local *axi_create(u32 priv_len)
> +{
> + struct axi_local *inst;
> + int size = ALIGN(sizeof(*inst), 4) + priv_len;
> +
> + inst = kzalloc(size, GFP_ATOMIC);

Hmm, ATOMIC without checking the retval. This is prepared for its first
crash under a high memory pressure.

> + try_module_get(THIS_MODULE);
> +
> + return inst;
> +}
> +struct axi_instance *axi_open(void *regs, u32 erombase, u32 priv_len)
> +{
> + struct axi_local *inst = axi_create(priv_len);
> +
> + /* fill public fields */
> + inst->pub.regs = regs;
> + inst->pub.priv = (char *)inst + ALIGN(sizeof(*inst), 4);
> +
> + inst->enum_rom_ptr = ioremap_nocache((unsigned long)erombase,
> + AXI_CORE_SIZE);

Check retval.

> + return &inst->pub;
> +}
...

regards,
--
js
suse labs
--
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/