Skip to contentSkip to conversation

use of uninitialized pointer in jffs_create()

DISCUSSION Jesper Juhl 5 participants 7 messages Aug 20, 2005 – Aug 23, 2005

lore
Share & tools
lore
#0 lore raw

gcc kindly pointed me at jffs_create() with this warning :

fs/jffs/inode-v23.c:1279: warning: `inode' might be used uninitialized in this function

And looking at the function :

static int
jffs_create(struct inode *dir, struct dentry *dentry, int mode,
struct nameidata *nd)

{
        struct jffs_raw_inode raw_inode;
        struct jffs_control *c;
        struct jffs_node *node;
        struct jffs_file *dir_f; /* JFFS representation of the directory.  */
        struct inode *inode;
        int err;

        truncate_inode_pages(&inode->i_data, 0);

...

I think it is correct. How on earth is that call to truncate_inode_pages() going to avoid blowing up? inode has not yet been initialized... Looks like a bug to me. Unfortunately I don't know anything about this code, so I haven't attempted to fix it.

Signature · 3 lines
Jesper Juhl <[email protected]>
Don't top-post  http://www.catb.org/~esr/jargon/html/T/top-post.html
Plain text mails only, please      http://www.expita.com/nomime.html
#1 lore raw
Quoted 4 lines · Jesper Juhl

gcc kindly pointed me at jffs_create() with this warning :

fs/jffs/inode-v23.c:1279: warning: `inode' might be used uninitialized in this function

I don't see a warning with latest gcc-4.1 snapshot.

Quoted 5 lines

And looking at the function :

static int
jffs_create(struct inode *dir, struct dentry *dentry, int mode,
struct nameidata *nd)

Quoted 9 lines
{
        struct jffs_raw_inode raw_inode;
        struct jffs_control *c;
        struct jffs_node *node;
        struct jffs_file *dir_f; /* JFFS representation of the directory.  */
        struct inode *inode;
        int err;

        truncate_inode_pages(&inode->i_data, 0);
$ grep truncate_inode_pages -r fs/jffs/
$
	?
Quoted 3 lines

I think it is correct. How on earth is that call to truncate_inode_pages() going to avoid blowing up? inode has not yet been initialized...

#2 lore raw
Quoted 8 lines · Alexey Dobriyan
Quoted 4 lines · Jesper Juhl

gcc kindly pointed me at jffs_create() with this warning :

fs/jffs/inode-v23.c:1279: warning: `inode' might be used uninitialized in this function

I don't see a warning with latest gcc-4.1 snapshot.

I'm using gcc 3.3.6, and the kernel that shows this warning is 2.6.13-rc6-mm1

Signature · 3 lines
Jesper Juhl <[email protected]>
Don't top-post  http://www.catb.org/~esr/jargon/html/T/top-post.html
Plain text mails only, please      http://www.expita.com/nomime.html
#4 lore raw
In reply to Jesper Juhl
Quoted 5 lines · Jesper Juhl

gcc kindly pointed me at jffs_create() with this warning :

fs/jffs/inode-v23.c:1279: warning: `inode' might be used uninitialized in this function

Real fix would be to finally remove that code. Except for the usual "change this function in the whole kernel" stuff, noone has touched it for ages.

Jörn

Signature · 3 lines
Man darf nicht das, was uns unwahrscheinlich und unnatürlich erscheint,
mit dem verwechseln, was absolut unmöglich ist.
-- Carl Friedrich Gauß
#3 lore raw
In reply to Jesper Juhl

Le Sunday 21 August 2005 a 13:08, Jesper Juhl ecrivait:

Quoted 12 lines · Alexey Dobriyan
Quoted 8 lines · Jesper Juhl
Quoted 4 lines

gcc kindly pointed me at jffs_create() with this warning :

fs/jffs/inode-v23.c:1279: warning: `inode' might be used uninitialized in this function

I don't see a warning with latest gcc-4.1 snapshot.

I'm using gcc 3.3.6, and the kernel that shows this warning is 2.6.13-rc6-mm1 From a copy of the Linus's repository.

stephane@debian:~/devel/linux-2.6$ head -5 Makefile
VERSION = 2
PATCHLEVEL = 6
SUBLEVEL = 13
EXTRAVERSION =-rc6
NAME=Woozy Numbat
stephane@debian:~/devel/linux-2.6/fs/jffs$ grep truncate * -rn
intrep.c:2452:             of the file system if a large file have been
truncated,
stephane@debian:~/devel/linux-2.6/fs/jffs$

Stephane

Signature · 2 lines
Stephane Wirtel <[email protected]>
                <[email protected]>
#5 lore raw
In reply to Jörn Engel
Quoted 10 lines · Jörn Engel
Quoted 5 lines · Jesper Juhl

gcc kindly pointed me at jffs_create() with this warning :

fs/jffs/inode-v23.c:1279: warning: `inode' might be used uninitialized in this function

Real fix would be to finally remove that code. Except for the usual "change this function in the whole kernel" stuff, noone has touched it for ages.

That's wrong, this -mm specific bug comes git-ocfs2.patch .

Quoted 1 line

Jörn

cu
Adrian

Signature · 4 lines
       "Is there not promise of rain?" Ling Tan asked suddenly out
        of the darkness. There had been need of rain for many days.
       "Only a promise," Lao Er said.
                                       Pearl S. Buck - Dragon Seed
#6 lore raw
Quoted 5 lines · Adrian Bunk
Quoted 4 lines · Jörn Engel
Quoted 3 lines · Jesper Juhl

gcc kindly pointed me at jffs_create() with this warning :

Quoted 8 lines
Quoted 6 lines
Quoted 2 lines

fs/jffs/inode-v23.c:1279: warning: `inode' might be used uninitialized in this function

Real fix would be to finally remove that code. Except for the usual "change this function in the whole kernel" stuff, noone has touched it for ages.

That's wrong, this -mm specific bug comes git-ocfs2.patch .

Ack. If I wasn't this lazy, I'd still propose to completely remove jffs - it's been old and deprecated for a few years already.

Jörn

Signature · 4 lines
Public Domain  - Free as in Beer
General Public - Free as in Speech
BSD License    - Free as in Enterprise
Shared Source  - Free as in "Work will make you..."