mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Julia Lawall <julia@diku.dk>
To: florian@openwrt.org, openwrt-devel@lists.openwrt.org,
	linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org
Subject: [PATCH 3/3] drivers/vlynq/vlynq.c: Fix resource size off by 1 error
Date: Sat, 4 Jul 2009 23:33:21 +0200 (CEST)	[thread overview]
Message-ID: <Pine.LNX.4.64.0907042332300.9841@ask.diku.dk> (raw)

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>

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

diff -u -p 
a/drivers/vlynq/vlynq.c 
b/drivers/vlynq/vlynq.c
--- a/drivers/vlynq/vlynq.c 2009-06-24 21:18:50.000000000 +0200
+++ b/drivers/vlynq/vlynq.c 2009-07-04 21:37:28.000000000 +0200
@@ -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));

             reply	other threads:[~2009-07-04 21:33 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-07-04 21:33 Julia Lawall [this message]
2009-07-05 11:23 ` Florian Fainelli

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Pine.LNX.4.64.0907042332300.9841@ask.diku.dk \
    --to=julia@diku.dk \
    --cc=florian@openwrt.org \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=openwrt-devel@lists.openwrt.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®