Skip to contentSkip to conversation

ubifs: fix uninitialized variable usage

PATCH In review Antonio Quartulli 2 participants 3 messages Nov 15, 2024 – Nov 18, 2024

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ubifs: fix uninitialized variable usage

In ubifs_jnl_write_inode(), when an inode cannot be deleted due to too many xattrs, err is passed to ubifs_ro_mode() uninitialized, thus leading to bogus error reporting.

Fix this case by passing -EPERM, which is the same value that ubifs_jnl_write_inode() is going to return to the caller.

This fixes 1 UNINIT issue reported by Coverity
Report: CID 1601860: Uninitialized scalar variable (UNINIT)

Cc Richard Weinberger <[email protected]>
Cc Zhihao Cheng <[email protected]>
Cc [email protected] (open list)
---
 fs/ubifs/journal.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/ubifs/journal.c +1 -1
index 8e98be642371..5eedf511880c 100644
@@ -983,7 +983,7 @@ int ubifs_jnl_write_inode(struct ubifs_info *c, const struct inode *inode)
 
 	if (kill_xattrs && ui->xattr_cnt > ubifs_xattr_max_cnt(c)) {
 		ubifs_err(c, "Cannot delete inode, it has too much xattrs!");
-		ubifs_ro_mode(c, err);
+		ubifs_ro_mode(c, -EPERM);
 		return -EPERM;
 	}
 
Signature · 1 line
2.45.2
reviewer
#1 lore raw
Quoted 10 lines · Antonio Quartulli

In ubifs_jnl_write_inode(), when an inode cannot be deleted due to too many xattrs, err is passed to ubifs_ro_mode() uninitialized, thus leading to bogus error reporting.

Fix this case by passing -EPERM, which is the same value that ubifs_jnl_write_inode() is going to return to the caller.

This fixes 1 UNINIT issue reported by Coverity
Report: CID 1601860: Uninitialized scalar variable (UNINIT)

Quoted 7 lines
Cc Richard Weinberger <[email protected]>
Cc Zhihao Cheng <[email protected]>
Cc [email protected] (open list)
---
  fs/ubifs/journal.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)

Hi Antonio, thanks for the patch. Nathan has sent a patch to fix it.
https://lore.kernel.org/linux-mtd/[email protected]/T/#t

Quoted 15 lines
fs/ubifs/journal.c +1 -1
index 8e98be642371..5eedf511880c 100644
@@ -983,7 +983,7 @@ int ubifs_jnl_write_inode(struct ubifs_info *c, const struct inode *inode)
 
  	if (kill_xattrs && ui->xattr_cnt > ubifs_xattr_max_cnt(c)) {
  		ubifs_err(c, "Cannot delete inode, it has too much xattrs!");
-		ubifs_ro_mode(c, err);
+		ubifs_ro_mode(c, -EPERM);
  		return -EPERM;
  	}
 
#2 lore raw
Quoted 19 lines · Zhihao Cheng
Quoted 10 lines · Antonio Quartulli

In ubifs_jnl_write_inode(), when an inode cannot be deleted due to too many xattrs, err is passed to ubifs_ro_mode() uninitialized, thus leading to bogus error reporting.

Fix this case by passing -EPERM, which is the same value that ubifs_jnl_write_inode() is going to return to the caller.

This fixes 1 UNINIT issue reported by Coverity
Report: CID 1601860: Uninitialized scalar variable (UNINIT)

Quoted 7 lines
Cc Richard Weinberger <[email protected]>
Cc Zhihao Cheng <[email protected]>
Cc [email protected] (open list)

---
  fs/ubifs/journal.c | 2 +-

  1 file changed, 1 insertion(+), 1 deletion(-)
Quoted 2 lines

Hi Antonio, thanks for the patch. Nathan has sent a patch to fix it.
https://lore.kernel.org/linux-mtd/ [email protected]/T/#t

Perfect!
Thanks for letting me know.

Regards,

Signature · 5 lines
Antonio Quartulli

CEO and Co-Founder
Mandelbit Srl
https://www.mandelbit.com