Skip to content

Commit 3354f73

Browse files
Julia Lawalltorvalds
authored andcommitted
drivers/vlynq/vlynq.c: fix resource size off by 1 error
In this case, the calls to request_mem_region, ioremap, and release_mem_region all have a consistent length argument, len, but since in other files (res->end - res->start) + 1, equivalent to resource_size(res), is used for a resource-typed structure res, one could consider whether the same should be done here. The problem was found using the following semantic patch: (http://www.emn.fr/x-info/coccinelle/) // <smpl> @@ struct resource *res; @@ - (res->end - res->start) + 1 + resource_size(res) @@ struct resource *res; @@ - res->end - res->start + BAD(resource_size(res)) // </smpl> Signed-off-by: Julia Lawall <julia@diku.dk> Acked-by: Florian Fainelli <florian@openwrt.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent a21f3c2 commit 3354f73

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

‎drivers/vlynq/vlynq.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -702,7 +702,7 @@ static int vlynq_probe(struct platform_device *pdev)
702702
dev->mem_start = mem_res->start;
703703
dev->mem_end = mem_res->end;
704704

705-
len = regs_res->end - regs_res->start;
705+
len = resource_size(regs_res);
706706
if (!request_mem_region(regs_res->start, len, dev_name(&dev->dev))) {
707707
printk(KERN_ERR "%s: Can't request vlynq registers\n",
708708
dev_name(&dev->dev));

0 commit comments

Comments
 (0)