ubifs: Call ubifs_iput when ubifs_iget is used
RFC PATCH 1/1 ubifs: Call ubifs_iput when ubifs_iget is used
The inode should be freed after a reference is get to avoid memory leak
--- fs/ubifs/ubifs.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)
fs/ubifs/ubifs.c +6 -3
@@ -319,9 +319,7 @@ static int filldir(struct ubifs_info *c, const char *name, int namlen, }ctime_r ((time_t *)&inode->i_mtime, filetime);printf ("%9lld %24.24s " , inode->i_size, filetime); -#ifndef __UBOOT__ubifs_iput (inode); -#endif printf ("%s\n" , name);
@@ -557,6 +555,7 @@ static unsigned long ubifs_findfile(struct super_block *sb, char *filename)/* We have some sort of symlink recursion, bail out */ if (symlink_count++ >8 ) { +ubifs_iput (inode);printf ("Symlink recursion, aborting\n" );return 0 ; }
@@ -568,6 +567,7 @@ static unsigned long ubifs_findfile(struct super_block *sb, char *filename)* the leading slash */ next = name = link_name +1 ; root_inum =1 ; +ubifs_iput (inode);continue ; }/* Relative to cur dir */
@@ -575,6 +575,7 @@ static unsigned long ubifs_findfile(struct super_block *sb, char *filename) link_name, next == NULL ? "" : next);memcpy (symlinkpath, buf,sizeof (buf)); next = name = symlinkpath; +ubifs_iput (inode);continue ; }
@@ -583,8 +584,10 @@ static unsigned long ubifs_findfile(struct super_block *sb, char *filename)*/ /* Found the node! */ -if (!next || *next =='\0' ) +if (!next || *next =='\0' ) { +ubifs_iput (inode);return inum; + } root_inum = inum; name = next;
Signature · 1 line
2.43.0
Hello Michael,
Quoted 7 lines · Michael Trimarchi
The inode should be freed after a reference is get to avoid memory leak
Signed-off-by Michael Trimarchi <[email protected]>--- fs/ubifs/ubifs.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)
As discussed, that patch looks valid to me!
It would be good to have some testers...
Looking through the code, I think there is one more place:
$ git diff
fs/ubifs/super.c +1 -0
@@ -2322,6 +2322,7 @@ static int ubifs_fill_super(struct super_block *sb, void *data, int silent) }#else sb->s_root =NULL ; +ubifs_iput (inode);#endif mutex_unlock (&c->umount_mutex);
$
What do you mean?
bye,
Heiko
Signature · 3 lines
DENX Software Engineering GmbH, Managing Director: Erika Unter HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: +49-8142-66989-52 Fax: +49-8142-66989-80 Email: [email protected]
Hi Heiko
Quoted 24 lines · Heiko Schocher
Hello Michael,
Quoted 7 lines · Michael Trimarchi
The inode should be freed after a reference is get to avoid memory leak
Signed-off-by Michael Trimarchi <[email protected]>--- fs/ubifs/ubifs.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)As discussed, that patch looks valid to me!
It would be good to have some testers...
Looking through the code, I think there is one more place:
$ git difffs/ubifs/super.c +0
-0
fs/ubifs/super.c static int ubifs_fill_super(struct super_block *sb, void *data, int silent) · line 2327
Quoted 6 lines
fs/ubifs/super.c +1
-0@@ -2322,6 +2322,7 @@ static int ubifs_fill_super(struct super_block *sb, void *data, int silent) }#else sb->s_root =NULL ; +ubifs_iput (inode);#endif
Right, I think that people are reporting now those problem can try to give a quick try on it
Michael
Quoted 11 lines
fs/ubifs/super.c +0
-0mutex_unlock (&c->umount_mutex);$
What do you mean?
bye,
Heiko
--
DENX Software Engineering GmbH, Managing Director: Erika Unter
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-52 Fax: +49-8142-66989-80 Email: [email protected]
--
Michael Nazzareno Trimarchi
Co-Founder & Chief Executive Officer
M. +39 347 913 2170
[email protected]
__________________________________
Amarula Solutions BV
Joop Geesinkweg 125, 1114 AB, Amsterdam, NL
T. +31 (0)85 111 9172
[email protected]
www.amarulasolutions.com
Hello Michael,
Am Mon, Aug 05, 2024 at 07:31:40PM +0200 schrieb Michael Trimarchi:
Quoted 4 lines
The inode should be freed after a reference is get to avoid memory leak
Signed-off-by Michael Trimarchi <[email protected]>
Tested this on top of my recent ubifs series. No obvious problems found on U-Boot command line with various combinations of commands, no crashes, so …
Greets
Alex
Quoted 57 lines
--- fs/ubifs/ubifs.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)fs/ubifs/ubifs.c +6
-3@@ -319,9 +319,7 @@ static int filldir(struct ubifs_info *c, const char *name, int namlen, }ctime_r ((time_t *)&inode->i_mtime, filetime);printf ("%9lld %24.24s " , inode->i_size, filetime); -#ifndef __UBOOT__ubifs_iput (inode); -#endif printf ("%s\n" , name);@@ -557,6 +555,7 @@ static unsigned long ubifs_findfile(struct super_block *sb, char *filename)/* We have some sort of symlink recursion, bail out */ if (symlink_count++ >8 ) { +ubifs_iput (inode);printf ("Symlink recursion, aborting\n" );return 0 ; }@@ -568,6 +567,7 @@ static unsigned long ubifs_findfile(struct super_block *sb, char *filename)* the leading slash */ next = name = link_name +1 ; root_inum =1 ; +ubifs_iput (inode);continue ; }/* Relative to cur dir */ @@ -575,6 +575,7 @@ static unsigned long ubifs_findfile(struct super_block *sb, char *filename) link_name, next == NULL ? "" : next);memcpy (symlinkpath, buf,sizeof (buf)); next = name = symlinkpath; +ubifs_iput (inode);continue ; }@@ -583,8 +584,10 @@ static unsigned long ubifs_findfile(struct super_block *sb, char *filename)*/ /* Found the node! */ -if (!next || *next =='\0' ) +if (!next || *next =='\0' ) { +ubifs_iput (inode);return inum; + } root_inum = inum; name = next;Signature · 1 line
2.43.0
Hi Alexander
Quoted 7 lines · Alexander Dahl
Hello Michael,
Am Mon, Aug 05, 2024 at 07:31:40PM +0200 schrieb Michael Trimarchi:
Quoted 3 lines
The inode should be freed after a reference is get to avoid memory leak
Quoted 8 lines
Quoted 1 line
Signed-off-by Michael Trimarchi <[email protected]>Tested this on top of my recent ubifs series. No obvious problems found on U-Boot command line with various combinations of commands, no crashes, so …
Tested-by Alexander Dahl <[email protected]>
I think that we can resend including last heiko remark and let heiko to pick it from his own tree
Heiko I will add CoDevelopment if it's ok for you
Michael
Quoted 60 lines
Greets
AlexQuoted 57 lines
--- fs/ubifs/ubifs.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)fs/ubifs/ubifs.c +6
-4@@ -319,9 +319,7 @@ static int filldir(struct ubifs_info *c, const char *name, int namlen, }ctime_r ((time_t *)&inode->i_mtime, filetime);printf ("%9lld %24.24s " , inode->i_size, filetime); -#ifndef __UBOOT__ubifs_iput (inode); -#endif printf ("%s\n" , name);@@ -557,6 +555,7 @@ static unsigned long ubifs_findfile(struct super_block *sb, char *filename)/* We have some sort of symlink recursion, bail out */ if (symlink_count++ >8 ) { +ubifs_iput (inode);printf ("Symlink recursion, aborting\n" );return 0 ; }@@ -568,6 +567,7 @@ static unsigned long ubifs_findfile(struct super_block *sb, char *filename)* the leading slash */ next = name = link_name +1 ; root_inum =1 ; +ubifs_iput (inode);continue ; }/* Relative to cur dir */ @@ -575,6 +575,7 @@ static unsigned long ubifs_findfile(struct super_block *sb, char *filename) link_name, next == NULL ? "" : next);memcpy (symlinkpath, buf,sizeof (buf)); next = name = symlinkpath; +ubifs_iput (inode);continue ; }@@ -583,8 +584,10 @@ static unsigned long ubifs_findfile(struct super_block *sb, char *filename)*/ /* Found the node! */ -if (!next || *next =='\0' ) +if (!next || *next =='\0' ) { +ubifs_iput (inode);return inum; + } root_inum = inum; name = next; --2.43.0
Signature · 11 lines
Michael Nazzareno Trimarchi Co-Founder & Chief Executive Officer M. +39 347 913 2170 [email protected] __________________________________ Amarula Solutions BV Joop Geesinkweg 125, 1114 AB, Amsterdam, NL T. +31 (0)85 111 9172 [email protected] www.amarulasolutions.com
Quoted 16 lines · Michael Nazzareno Trimarchi
Hi Alexander
Quoted 13 lines · Alexander Dahl
Hello Michael,
Am Mon, Aug 05, 2024 at 07:31:40PM +0200 schrieb Michael Trimarchi:
Quoted 4 lines
The inode should be freed after a reference is get to avoid memory leak
Signed-off-by Michael Trimarchi <[email protected]>Tested this on top of my recent ubifs series. No obvious problems found on U-Boot command line with various combinations of commands, no crashes, so …
Quoted 7 lines
Quoted 2 lines
Tested-by Alexander Dahl <[email protected]>I think that we can resend including last heiko remark and let heiko to pick it from his own tree
Heiko I will add CoDevelopment if it's ok for you
Fine for me! Thanks!
bye,
Heiko
Quoted 67 lines
Michael
Quoted 60 lines
Greets
AlexQuoted 57 lines
--- fs/ubifs/ubifs.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)fs/ubifs/ubifs.c +6
-4@@ -319,9 +319,7 @@ static int filldir(struct ubifs_info *c, const char *name, int namlen, }ctime_r ((time_t *)&inode->i_mtime, filetime);printf ("%9lld %24.24s " , inode->i_size, filetime); -#ifndef __UBOOT__ubifs_iput (inode); -#endif printf ("%s\n" , name);@@ -557,6 +555,7 @@ static unsigned long ubifs_findfile(struct super_block *sb, char *filename)/* We have some sort of symlink recursion, bail out */ if (symlink_count++ >8 ) { +ubifs_iput (inode);printf ("Symlink recursion, aborting\n" );return 0 ; }@@ -568,6 +567,7 @@ static unsigned long ubifs_findfile(struct super_block *sb, char *filename)* the leading slash */ next = name = link_name +1 ; root_inum =1 ; +ubifs_iput (inode);continue ; }/* Relative to cur dir */ @@ -575,6 +575,7 @@ static unsigned long ubifs_findfile(struct super_block *sb, char *filename) link_name, next == NULL ? "" : next);memcpy (symlinkpath, buf,sizeof (buf)); next = name = symlinkpath; +ubifs_iput (inode);continue ; }@@ -583,8 +584,10 @@ static unsigned long ubifs_findfile(struct super_block *sb, char *filename)*/ /* Found the node! */ -if (!next || *next =='\0' ) +if (!next || *next =='\0' ) { +ubifs_iput (inode);return inum; + } root_inum = inum; name = next; --2.43.0
Signature · 3 lines
DENX Software Engineering GmbH, Managing Director: Erika Unter HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: +49-8142-66989-52 Fax: +49-8142-66989-80 Email: [email protected]