Re: [PATCH] UIO: Implement a UIO interface for the SMX Cryptengine

From: Paul Mundt
Date: Wed Mar 12 2008 - 06:09:12 EST


On Tue, Mar 11, 2008 at 03:57:10PM +1100, Ben Nizette wrote:
> + regs = platform_get_resource(dev, IORESOURCE_MEM, 0);
> + if (!regs)
> + goto out_free;
> +
> + info->mem[0].addr = regs->start;
> + if (!info->mem[0].addr)
> + goto out_free;
> + info->mem[0].internal_addr = ioremap(regs->start, regs->end -
> regs->start);
> + if (!info->mem[0].internal_addr)
> + goto out_free;
> +
> + info->mem[0].size = regs->end - regs->start;
> + info->mem[0].memtype = UIO_MEM_PHYS;
> +
You have an off-by-1 in the resource size. ioremap and struct resource
are not equal in their expectations. You probably want to do something
like:

info->mem[0].size = regs->end - regs->start + 1;
info->mem[0].internal_addr = ioremap(regs->start, info->mem[0].size);
...

and make sure that your resource end doesn't overlap with a start address
of an unrelated resource in your definition. /proc/iomem tends to be
useful for this.
--
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/