All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] FS-Cache: Add missing initialization of ret in cachefiles_write_page()
@ 2015-11-11 23:02 Geert Uytterhoeven
  2015-11-12 10:15 ` David Howells
  0 siblings, 1 reply; 5+ messages in thread
From: Geert Uytterhoeven @ 2015-11-11 23:02 UTC (permalink / raw)
  To: David Howells, Al Viro; +Cc: linux-cachefs, linux-kernel, Geert Uytterhoeven

fs/cachefiles/rdwr.c: In function ‘cachefiles_write_page’:
fs/cachefiles/rdwr.c:882: warning: ‘ret’ may be used uninitialized in
this function

If the jump to label "error" is taken, "ret" will indeed be
uninitialized, and random stack data may be printed by the debug code.

Fixes: 102f4d900c9c8f5e ("FS-Cache: Handle a write to the page immediately beyond the EOF marker")
Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
---
 fs/cachefiles/rdwr.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/cachefiles/rdwr.c b/fs/cachefiles/rdwr.c
index 7a6b02f727874352..bdd28fe9a7f7195b 100644
--- a/fs/cachefiles/rdwr.c
+++ b/fs/cachefiles/rdwr.c
@@ -879,7 +879,7 @@ int cachefiles_write_page(struct fscache_storage *op, struct page *page)
 	loff_t pos, eof;
 	size_t len;
 	void *data;
-	int ret;
+	int ret = 0;
 
 	ASSERT(op != NULL);
 	ASSERT(page != NULL);
-- 
1.9.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] FS-Cache: Add missing initialization of ret in cachefiles_write_page()
  2015-11-11 23:02 [PATCH] FS-Cache: Add missing initialization of ret in cachefiles_write_page() Geert Uytterhoeven
@ 2015-11-12 10:15 ` David Howells
  2015-11-12 10:23   ` Geert Uytterhoeven
  2015-11-12 10:42   ` David Howells
  0 siblings, 2 replies; 5+ messages in thread
From: David Howells @ 2015-11-12 10:15 UTC (permalink / raw)
  To: Geert Uytterhoeven; +Cc: dhowells, Al Viro, linux-cachefs, linux-kernel

Geert Uytterhoeven <geert@linux-m68k.org> wrote:

> -	int ret;
> +	int ret = 0;

This isn't quite the right solution.  The uninitialised error path needs to
set -ENOBUFS.  Unfortunately, my compiler doesn't show a warning:-/

David

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] FS-Cache: Add missing initialization of ret in cachefiles_write_page()
  2015-11-12 10:15 ` David Howells
@ 2015-11-12 10:23   ` Geert Uytterhoeven
  2015-11-12 10:42   ` David Howells
  1 sibling, 0 replies; 5+ messages in thread
From: Geert Uytterhoeven @ 2015-11-12 10:23 UTC (permalink / raw)
  To: David Howells; +Cc: Al Viro, linux-cachefs, linux-kernel

Hi David,

On Thu, Nov 12, 2015 at 11:15 AM, David Howells <dhowells@redhat.com> wrote:
> Geert Uytterhoeven <geert@linux-m68k.org> wrote:
>
>> -     int ret;
>> +     int ret = 0;
>
> This isn't quite the right solution.  The uninitialised error path needs to
> set -ENOBUFS.

That's what your commit 102f4d900c9c8f5e ("FS-Cache: Handle a write to the
page immediately beyond the EOF marker") does, and is also in its commit
description:

    Whilst we're at it, change the triggered assertion in CacheFiles to just
    return -ENOBUFS instead.

"ret" is used only to print the original error in a debug message.

> Unfortunately, my compiler doesn't show a warning:-/

Need old gcc (4.1.2 ;-)

Gr{oetje,eeting}s,

                        Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] FS-Cache: Add missing initialization of ret in cachefiles_write_page()
  2015-11-12 10:15 ` David Howells
  2015-11-12 10:23   ` Geert Uytterhoeven
@ 2015-11-12 10:42   ` David Howells
  2015-11-12 10:43     ` Geert Uytterhoeven
  1 sibling, 1 reply; 5+ messages in thread
From: David Howells @ 2015-11-12 10:42 UTC (permalink / raw)
  To: Geert Uytterhoeven; +Cc: dhowells, Al Viro, linux-cachefs, linux-kernel

Geert Uytterhoeven <geert@linux-m68k.org> wrote:

> > This isn't quite the right solution.  The uninitialised error path needs to
> > set -ENOBUFS.
> 
> That's what your commit 102f4d900c9c8f5e ("FS-Cache: Handle a write to the
> page immediately beyond the EOF marker") does, and is also in its commit
> description:
> 
>     Whilst we're at it, change the triggered assertion in CacheFiles to just
>     return -ENOBUFS instead.
> 
> "ret" is used only to print the original error in a debug message.

I'll adjust your patch to set the default value in ret to be -ENOBUFS instead
of 0.

> > Unfortunately, my compiler doesn't show a warning:-/
> 
> Need old gcc (4.1.2 ;-)

Quite possibly - gcc-5.1 does seem to be a bit lacking in detection of such
things.

David

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] FS-Cache: Add missing initialization of ret in cachefiles_write_page()
  2015-11-12 10:42   ` David Howells
@ 2015-11-12 10:43     ` Geert Uytterhoeven
  0 siblings, 0 replies; 5+ messages in thread
From: Geert Uytterhoeven @ 2015-11-12 10:43 UTC (permalink / raw)
  To: David Howells; +Cc: Al Viro, linux-cachefs, linux-kernel

On Thu, Nov 12, 2015 at 11:42 AM, David Howells <dhowells@redhat.com> wrote:
> Geert Uytterhoeven <geert@linux-m68k.org> wrote:
>
>> > This isn't quite the right solution.  The uninitialised error path needs to
>> > set -ENOBUFS.
>>
>> That's what your commit 102f4d900c9c8f5e ("FS-Cache: Handle a write to the
>> page immediately beyond the EOF marker") does, and is also in its commit
>> description:
>>
>>     Whilst we're at it, change the triggered assertion in CacheFiles to just
>>     return -ENOBUFS instead.
>>
>> "ret" is used only to print the original error in a debug message.
>
> I'll adjust your patch to set the default value in ret to be -ENOBUFS instead
> of 0.

OK. Thanks!

Gr{oetje,eeting}s,

                        Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2015-11-12 10:43 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-11-11 23:02 [PATCH] FS-Cache: Add missing initialization of ret in cachefiles_write_page() Geert Uytterhoeven
2015-11-12 10:15 ` David Howells
2015-11-12 10:23   ` Geert Uytterhoeven
2015-11-12 10:42   ` David Howells
2015-11-12 10:43     ` Geert Uytterhoeven

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.