lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20110407160142.0a9d399c.akpm@linux-foundation.org>
Date:	Thu, 7 Apr 2011 16:01:42 -0700
From:	Andrew Morton <akpm@...ux-foundation.org>
To:	Julia Lawall <julia@...u.dk>
Cc:	Alessandro Zummo <a.zummo@...ertech.it>,
	kernel-janitors@...r.kernel.org, rtc-linux@...glegroups.com,
	linux-kernel@...r.kernel.org
Subject: Re: [PATCH] drivers/rtc/rtc-mrst.c: Use release_mem_region after
 request_mem_region

On Mon, 14 Mar 2011 22:00:25 +0100
Julia Lawall <julia@...u.dk> wrote:

> The memory allocated using request_mem_region should be released using
> release_mem_region, not release_region.
> 
> The semantic patch that fixes part of this problem is as follows:
> (http://coccinelle.lip6.fr/)
> 
> // <smpl>
> @@
> expression E1,E2,E3;
> @@
> 
> request_mem_region(E1,E2,E3)
> ...
> ?- release_region(E1,E2)
> + release_mem_region(E1,E2)
> // </smpl>
> 
> Signed-off-by: Julia Lawall <julia@...u.dk>
> 
> ---
>  drivers/rtc/rtc-mrst.c |    4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/rtc/rtc-mrst.c b/drivers/rtc/rtc-mrst.c
> index b86bc32..558dd7d 100644
> --- a/drivers/rtc/rtc-mrst.c
> +++ b/drivers/rtc/rtc-mrst.c
> @@ -379,7 +379,7 @@ cleanup1:
>  	mrst_rtc.dev = NULL;
>  	rtc_device_unregister(mrst_rtc.rtc);
>  cleanup0:
> -	release_region(iomem->start, iomem->end + 1 - iomem->start);
> +	release_mem_region(iomem->start, iomem->end + 1 - iomem->start);
>  	dev_err(dev, "rtc-mrst: unable to initialise\n");
>  	return retval;
>  }
> @@ -405,7 +405,7 @@ static void __exit rtc_mrst_do_remove(struct device *dev)
>  	mrst->rtc = NULL;
>  
>  	iomem = mrst->iomem;
> -	release_region(iomem->start, iomem->end + 1 - iomem->start);
> +	release_mem_region(iomem->start, iomem->end + 1 - iomem->start);
>  	mrst->iomem = NULL;
>  
>  	mrst->dev = NULL;

We may as well clean this up too.

--- a/drivers/rtc/rtc-mrst.c~drivers-rtc-rtc-mrstc-use-release_mem_region-after-request_mem_region-fix
+++ a/drivers/rtc/rtc-mrst.c
@@ -380,7 +380,7 @@ cleanup1:
 cleanup0:
 	dev_set_drvdata(dev, NULL);
 	mrst_rtc.dev = NULL;
-	release_mem_region(iomem->start, iomem->end + 1 - iomem->start);
+	release_mem_region(iomem->start, resource_size(iomem));
 	dev_err(dev, "rtc-mrst: unable to initialise\n");
 	return retval;
 }
@@ -406,7 +406,7 @@ static void __devexit rtc_mrst_do_remove
 	mrst->rtc = NULL;
 
 	iomem = mrst->iomem;
-	release_mem_region(iomem->start, iomem->end + 1 - iomem->start);
+	release_mem_region(iomem->start, resource_size(iomem));
 	mrst->iomem = NULL;
 
 	mrst->dev = NULL;
_

which makes one wonder why we don't have

void release_resource_mem(struct resource *r)
{
	release_mem_region(r->start, resource_size(r));
}
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ