* [PATCH] ubifs: Fix uninitialized use of err in ubifs_jnl_write_inode()
@ 2024-11-15 16:10 Nathan Chancellor
2024-11-15 16:46 ` Richard Weinberger
2024-11-16 1:57 ` Zhihao Cheng
0 siblings, 2 replies; 3+ messages in thread
From: Nathan Chancellor @ 2024-11-15 16:10 UTC (permalink / raw)
To: Richard Weinberger, Zhihao Cheng
Cc: linux-mtd, llvm, patches, Nathan Chancellor
Clang warns (or errors with CONFIG_WERROR=y):
fs/ubifs/journal.c:986:20: error: variable 'err' is uninitialized when used here [-Werror,-Wuninitialized]
986 | ubifs_ro_mode(c, err);
| ^~~
Set err to -EPERM before the call to ubifs_ro_mode() and reuse it in the
return statement to resolve the warning.
Fixes: 957e1c4e1779 ("ubifs: ubifs_jnl_write_inode: Only check once for the limitation of xattr count")
Signed-off-by: Nathan Chancellor <nathan@kernel.org>
---
fs/ubifs/journal.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/fs/ubifs/journal.c b/fs/ubifs/journal.c
index 8e98be64237154105cd6f7cb62cf0338ac26d3e9..36ba79fbd2ff80ff3d5c1f0bf965e439d8c55ab2 100644
--- a/fs/ubifs/journal.c
+++ b/fs/ubifs/journal.c
@@ -983,8 +983,9 @@ 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!");
+ err = -EPERM;
ubifs_ro_mode(c, err);
- return -EPERM;
+ return err;
}
/*
---
base-commit: fe051552f5078fa02d593847529a3884305a6ffe
change-id: 20241115-ubifs-fix-uninitialized-err-96ba6a1e756c
Best regards,
--
Nathan Chancellor <nathan@kernel.org>
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] ubifs: Fix uninitialized use of err in ubifs_jnl_write_inode()
2024-11-15 16:10 [PATCH] ubifs: Fix uninitialized use of err in ubifs_jnl_write_inode() Nathan Chancellor
@ 2024-11-15 16:46 ` Richard Weinberger
2024-11-16 1:57 ` Zhihao Cheng
1 sibling, 0 replies; 3+ messages in thread
From: Richard Weinberger @ 2024-11-15 16:46 UTC (permalink / raw)
To: Nathan Chancellor; +Cc: chengzhihao1, linux-mtd, llvm, patches
----- Ursprüngliche Mail -----
> Von: "Nathan Chancellor" <nathan@kernel.org>
> An: "richard" <richard@nod.at>, "chengzhihao1" <chengzhihao1@huawei.com>
> CC: "linux-mtd" <linux-mtd@lists.infradead.org>, "llvm" <llvm@lists.linux.dev>, "patches" <patches@lists.linux.dev>,
> "Nathan Chancellor" <nathan@kernel.org>
> Gesendet: Freitag, 15. November 2024 17:10:04
> Betreff: [PATCH] ubifs: Fix uninitialized use of err in ubifs_jnl_write_inode()
> Clang warns (or errors with CONFIG_WERROR=y):
>
> fs/ubifs/journal.c:986:20: error: variable 'err' is uninitialized when used here
> [-Werror,-Wuninitialized]
> 986 | ubifs_ro_mode(c, err);
> | ^~~
>
> Set err to -EPERM before the call to ubifs_ro_mode() and reuse it in the
> return statement to resolve the warning.
>
> Fixes: 957e1c4e1779 ("ubifs: ubifs_jnl_write_inode: Only check once for the
> limitation of xattr count")
> Signed-off-by: Nathan Chancellor <nathan@kernel.org>
That was fast, good catch!
Applied to -next.
Thanks,
//richard
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] ubifs: Fix uninitialized use of err in ubifs_jnl_write_inode()
2024-11-15 16:10 [PATCH] ubifs: Fix uninitialized use of err in ubifs_jnl_write_inode() Nathan Chancellor
2024-11-15 16:46 ` Richard Weinberger
@ 2024-11-16 1:57 ` Zhihao Cheng
1 sibling, 0 replies; 3+ messages in thread
From: Zhihao Cheng @ 2024-11-16 1:57 UTC (permalink / raw)
To: Nathan Chancellor, Richard Weinberger; +Cc: linux-mtd, llvm, patches
在 2024/11/16 0:10, Nathan Chancellor 写道:
> Clang warns (or errors with CONFIG_WERROR=y):
>
> fs/ubifs/journal.c:986:20: error: variable 'err' is uninitialized when used here [-Werror,-Wuninitialized]
> 986 | ubifs_ro_mode(c, err);
> | ^~~
>
> Set err to -EPERM before the call to ubifs_ro_mode() and reuse it in the
> return statement to resolve the warning.
>
> Fixes: 957e1c4e1779 ("ubifs: ubifs_jnl_write_inode: Only check once for the limitation of xattr count")
> Signed-off-by: Nathan Chancellor <nathan@kernel.org>
> ---
> fs/ubifs/journal.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
My mistake, thanks for fixing it.
Reviewed-by: Zhihao Cheng <chengzhihao1@huawei.com>
>
> diff --git a/fs/ubifs/journal.c b/fs/ubifs/journal.c
> index 8e98be64237154105cd6f7cb62cf0338ac26d3e9..36ba79fbd2ff80ff3d5c1f0bf965e439d8c55ab2 100644
> --- a/fs/ubifs/journal.c
> +++ b/fs/ubifs/journal.c
> @@ -983,8 +983,9 @@ 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!");
> + err = -EPERM;
> ubifs_ro_mode(c, err);
> - return -EPERM;
> + return err;
> }
>
> /*
>
> ---
> base-commit: fe051552f5078fa02d593847529a3884305a6ffe
> change-id: 20241115-ubifs-fix-uninitialized-err-96ba6a1e756c
>
> Best regards,
>
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2024-11-16 1:58 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-11-15 16:10 [PATCH] ubifs: Fix uninitialized use of err in ubifs_jnl_write_inode() Nathan Chancellor
2024-11-15 16:46 ` Richard Weinberger
2024-11-16 1:57 ` Zhihao Cheng
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox