>From 6c4eb2ce2849308c4a745ec1f93001e5064a469c Mon Sep 17 00:00:00 2001
From: Serge Hallyn <[email protected]>
Date: Wed, 11 Jun 2008 11:20:28 -0500
Subject: [PATCH -mm] mm/shmem.c: ret can be used uninitialized
Make sure ret is defined before check at line 1408.
Signed-off-by: Serge Hallyn <[email protected]>
---
mm/shmem.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/mm/shmem.c b/mm/shmem.c
index ad24be7..b326ff2 100644
--- a/mm/shmem.c
+++ b/mm/shmem.c
@@ -1365,7 +1365,7 @@ repeat:
}
if (!filepage) {
- int ret;
+ int ret = 0;
spin_unlock(&info->lock);
filepage = shmem_alloc_page(gfp, info, idx);
--
1.5.4.3
On Wed, 11 Jun 2008 14:37:29 -0500 "Serge E. Hallyn" <[email protected]> wrote:
> >From 6c4eb2ce2849308c4a745ec1f93001e5064a469c Mon Sep 17 00:00:00 2001
> From: Serge Hallyn <[email protected]>
> Date: Wed, 11 Jun 2008 11:20:28 -0500
> Subject: [PATCH -mm] mm/shmem.c: ret can be used uninitialized
>
> Make sure ret is defined before check at line 1408.
>
> Signed-off-by: Serge Hallyn <[email protected]>
> ---
> mm/shmem.c | 2 +-
> 1 files changed, 1 insertions(+), 1 deletions(-)
>
> diff --git a/mm/shmem.c b/mm/shmem.c
> index ad24be7..b326ff2 100644
> --- a/mm/shmem.c
> +++ b/mm/shmem.c
> @@ -1365,7 +1365,7 @@ repeat:
> }
>
> if (!filepage) {
> - int ret;
> + int ret = 0;
>
> spin_unlock(&info->lock);
> filepage = shmem_alloc_page(gfp, info, idx);
Well yes. But it adds more text and uncommentedly adds an unnecessary
initialisation.
With a wee bit of thought we can _reduce_ the amount of text and not
add unnecessary stuff?
--- a/mm/shmem.c~memcg-remove-refcnt-from-page_cgroup-fix-2
+++ a/mm/shmem.c
@@ -1396,7 +1396,8 @@ repeat:
swap = *entry;
shmem_swp_unmap(entry);
}
- if (error || swap.val)
+ ret = error || swap.val;
+ if (ret)
mem_cgroup_uncharge_cache_page(filepage);
else
ret = add_to_page_cache_lru(filepage, mapping,
@@ -1405,7 +1406,7 @@ repeat:
* At add_to_page_cache_lru() failure, uncharge will
* be done automatically.
*/
- if (error || swap.val || ret) {
+ if (ret) {
spin_unlock(&info->lock);
page_cache_release(filepage);
shmem_unacct_blocks(info->flags, 1);
_
Quoting Andrew Morton ([email protected]):
> On Wed, 11 Jun 2008 14:37:29 -0500 "Serge E. Hallyn" <[email protected]> wrote:
>
> > >From 6c4eb2ce2849308c4a745ec1f93001e5064a469c Mon Sep 17 00:00:00 2001
> > From: Serge Hallyn <[email protected]>
> > Date: Wed, 11 Jun 2008 11:20:28 -0500
> > Subject: [PATCH -mm] mm/shmem.c: ret can be used uninitialized
> >
> > Make sure ret is defined before check at line 1408.
> >
> > Signed-off-by: Serge Hallyn <[email protected]>
> > ---
> > mm/shmem.c | 2 +-
> > 1 files changed, 1 insertions(+), 1 deletions(-)
> >
> > diff --git a/mm/shmem.c b/mm/shmem.c
> > index ad24be7..b326ff2 100644
> > --- a/mm/shmem.c
> > +++ b/mm/shmem.c
> > @@ -1365,7 +1365,7 @@ repeat:
> > }
> >
> > if (!filepage) {
> > - int ret;
> > + int ret = 0;
> >
> > spin_unlock(&info->lock);
> > filepage = shmem_alloc_page(gfp, info, idx);
>
> Well yes. But it adds more text and uncommentedly adds an unnecessary
> initialisation.
>
> With a wee bit of thought we can _reduce_ the amount of text and not
> add unnecessary stuff?
>
> --- a/mm/shmem.c~memcg-remove-refcnt-from-page_cgroup-fix-2
> +++ a/mm/shmem.c
> @@ -1396,7 +1396,8 @@ repeat:
> swap = *entry;
> shmem_swp_unmap(entry);
> }
> - if (error || swap.val)
> + ret = error || swap.val;
> + if (ret)
> mem_cgroup_uncharge_cache_page(filepage);
> else
> ret = add_to_page_cache_lru(filepage, mapping,
> @@ -1405,7 +1406,7 @@ repeat:
> * At add_to_page_cache_lru() failure, uncharge will
> * be done automatically.
> */
> - if (error || swap.val || ret) {
> + if (ret) {
> spin_unlock(&info->lock);
> page_cache_release(filepage);
> shmem_unacct_blocks(info->flags, 1);
> _
Neat.
-serge