From: Ethan Tidmore <ethantidmore06@gmail.com>
To: viro@zeniv.linux.org.uk, brauner@kernel.org
Cc: jack@suse.cz, amir73il@gmail.com, paul@paul-moore.com,
linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org,
Ethan Tidmore <ethantidmore06@gmail.com>
Subject: [PATCH] backing_file: Fix error code swallow
Date: Sun, 22 Mar 2026 18:26:55 -0500 [thread overview]
Message-ID: <20260322232655.1164614-1-ethantidmore06@gmail.com> (raw)
The macro WARN_ON() returns true if the condition inside is true. So if
there is an error with vfs_open() 1 is returned.
Capture the return value of vfs_open() then run WARN_ON() on it.
Detected by Smatch:
fs/backing-file.c:52 backing_file_open() warn:
passing positive error code '1' to 'ERR_PTR'
fs/backing-file.c:77 backing_tmpfile_open() warn:
passing positive error code '1' to 'ERR_PTR'
Fixes: 7ea30795d6b7d ("backing_file: store user_path_file")
Signed-off-by: Ethan Tidmore <ethantidmore06@gmail.com>
---
fs/file_table.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/fs/file_table.c b/fs/file_table.c
index e8b4eb2bbff8..0898b1816c14 100644
--- a/fs/file_table.c
+++ b/fs/file_table.c
@@ -69,8 +69,12 @@ EXPORT_SYMBOL_GPL(backing_file_user_path_file);
int backing_file_open_user_path(struct file *f, const struct path *path)
{
+ int ret;
+
/* open an O_PATH file to reference the user path - should not fail */
- return WARN_ON(vfs_open(path, &backing_file(f)->user_path_file));
+ ret = vfs_open(path, &backing_file(f)->user_path_file);
+ WARN_ON(ret);
+ return ret;
}
EXPORT_SYMBOL_GPL(backing_file_open_user_path);
--
2.53.0
next reply other threads:[~2026-03-22 23:27 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-22 23:26 Ethan Tidmore [this message]
2026-03-23 0:53 ` [PATCH] backing_file: Fix error code swallow Paul Moore
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260322232655.1164614-1-ethantidmore06@gmail.com \
--to=ethantidmore06@gmail.com \
--cc=amir73il@gmail.com \
--cc=brauner@kernel.org \
--cc=jack@suse.cz \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=paul@paul-moore.com \
--cc=viro@zeniv.linux.org.uk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox