mm-commits.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* + drivers-vlynq-vlynqc-fix-resource-size-off-by-1-error.patch added to -mm tree
@ 2009-07-20 19:44 akpm
  0 siblings, 0 replies; only message in thread
From: akpm @ 2009-07-20 19:44 UTC (permalink / raw)
  To: mm-commits; +Cc: julia, florian


The patch titled
     drivers/vlynq/vlynq.c: fix resource size off by 1 error
has been added to the -mm tree.  Its filename is
     drivers-vlynq-vlynqc-fix-resource-size-off-by-1-error.patch

Before you just go and hit "reply", please:
   a) Consider who else should be cc'ed
   b) Prefer to cc a suitable mailing list as well
   c) Ideally: find the original patch on the mailing list and do a
      reply-to-all to that, adding suitable additional cc's

*** Remember to use Documentation/SubmitChecklist when testing your code ***

See http://userweb.kernel.org/~akpm/stuff/added-to-mm.txt to find
out what to do about this

The current -mm tree may be found at http://userweb.kernel.org/~akpm/mmotm/

------------------------------------------------------
Subject: drivers/vlynq/vlynq.c: fix resource size off by 1 error
From: Julia Lawall <julia@diku.dk>

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>
---

 drivers/vlynq/vlynq.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff -puN drivers/vlynq/vlynq.c~drivers-vlynq-vlynqc-fix-resource-size-off-by-1-error drivers/vlynq/vlynq.c
--- a/drivers/vlynq/vlynq.c~drivers-vlynq-vlynqc-fix-resource-size-off-by-1-error
+++ a/drivers/vlynq/vlynq.c
@@ -703,7 +703,7 @@ static int vlynq_probe(struct platform_d
 	dev->mem_start = mem_res->start;
 	dev->mem_end = mem_res->end;
 
-	len = regs_res->end - regs_res->start;
+	len = resource_size(regs_res);
 	if (!request_mem_region(regs_res->start, len, dev_name(&dev->dev))) {
 		printk(KERN_ERR "%s: Can't request vlynq registers\n",
 		       dev_name(&dev->dev));
_

Patches currently in -mm which might be from julia@diku.dk are

origin.patch
linux-next.patch
drivers-video-imxfbc-fix-resource-size-off-by-1-error.patch
edac-fix-resource-size-calculation.patch
drivers-vlynq-vlynqc-fix-resource-size-off-by-1-error.patch


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2009-07-20 19:45 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-07-20 19:44 + drivers-vlynq-vlynqc-fix-resource-size-off-by-1-error.patch added to -mm tree akpm

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).