From: Viacheslav Dubeyko <slava@dubeyko.com>
To: Konstantin Adzer <info@massivetech.ru>,
Alexander Viro <viro@zeniv.linux.org.uk>,
Christian Brauner <brauner@kernel.org>
Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 2/3] hfs: return ERR_PTR() from hfs_iget()
Date: Tue, 01 Dec 2026 14:18:35 -0800 [thread overview]
Message-ID: <98eeb224a2bedd951956437ecf83a8e183bb3a20.camel@dubeyko.com> (raw)
In-Reply-To: <66c696d294765fa5692ba07a5dcc4e7a2b41887f.1796132090.git.info@massivetech.ru>
On Tue, 2026-12-01 at 16:06 +0300, Konstantin Adzer wrote:
> hfs_iget() returns NULL both for a catalog record that is neither a
> file nor a directory and for a failed iget5_locked(). hfs_lookup()
> turns
> that into -EACCES and hfs_fill_super() into -EINVAL.
>
> Return ERR_PTR(-EIO) for the unexpected record type, the error
> hfs_read_inode() returns for a bad record, and ERR_PTR(-ENOMEM) for a
> failed iget5_locked(), and pass the error on in both callers, so that
> hfs_iget() can forward the error of iget5_locked() once that returns
> ERR_PTR().
>
> Signed-off-by: Konstantin Adzer <info@massivetech.ru>
> ---
> fs/hfs/dir.c | 2 --
> fs/hfs/inode.c | 8 +++++---
> fs/hfs/super.c | 4 +++-
> 3 files changed, 8 insertions(+), 6 deletions(-)
>
> diff --git a/fs/hfs/dir.c b/fs/hfs/dir.c
> index f6b97da19788..b6b8945712a9 100644
> --- a/fs/hfs/dir.c
> +++ b/fs/hfs/dir.c
> @@ -35,8 +35,6 @@ static struct dentry *hfs_lookup(struct inode *dir,
> struct dentry *dentry,
> inode = ERR_PTR(res);
> } else {
> inode = hfs_iget(dir->i_sb, &fd.search_key->cat,
> &rec);
> - if (!inode)
> - inode = ERR_PTR(-EACCES);
> }
> hfs_find_exit(&fd);
> return d_splice_alias(inode, dentry);
> diff --git a/fs/hfs/inode.c b/fs/hfs/inode.c
> index 7e590e1308ea..b836b2f8d544 100644
> --- a/fs/hfs/inode.c
> +++ b/fs/hfs/inode.c
> @@ -433,7 +433,7 @@ static int hfs_read_inode(struct inode *inode,
> void *data)
> *
> * Given the MDB for a HFS filesystem, a 'key' and an 'entry' in
> * the catalog B-tree and the 'type' of the desired file return the
> - * inode for that file/directory or NULL. Note that 'type'
> indicates
> + * inode for that file/directory or an ERR_PTR(). Note that 'type'
> indicates
> * whether we want the actual file or directory, or the
> corresponding
> * metadata (AppleDouble header file or CAP metadata file).
> */
> @@ -451,10 +451,12 @@ struct inode *hfs_iget(struct super_block *sb,
> struct hfs_cat_key *key, hfs_cat_
> cnid = be32_to_cpu(rec->file.FlNum);
> break;
> default:
> - return NULL;
> + return ERR_PTR(-EIO);
> }
> inode = iget5_locked(sb, cnid, hfs_test_inode,
> hfs_read_inode, &data);
> - if (inode && (inode_state_read_once(inode) & I_NEW))
> + if (!inode)
> + return ERR_PTR(-ENOMEM);
> + if (inode_state_read_once(inode) & I_NEW)
> unlock_new_inode(inode);
> return inode;
> }
> diff --git a/fs/hfs/super.c b/fs/hfs/super.c
> index 7abc0e61a222..809da672fb0f 100644
> --- a/fs/hfs/super.c
> +++ b/fs/hfs/super.c
> @@ -378,8 +378,10 @@ static int hfs_fill_super(struct super_block
> *sb, struct fs_context *fc)
> res = -EINVAL;
> root_inode = hfs_iget(sb, &fd.search_key->cat, &rec);
> hfs_find_exit(&fd);
> - if (!root_inode)
> + if (IS_ERR(root_inode)) {
> + res = PTR_ERR(root_inode);
> goto bail_no_root;
> + }
>
> if (is_bad_inode(root_inode)) {
> iput(root_inode);
Thanks for the patch. However, this change is already in the HFS tree:
e124d2564bdb ("hfs: return ERR_PTR() from hfs_iget()")
It is in the for-next branch of [2] and was posted here [1].
Thanks,
Slava.
[1]
https://lore.kernel.org/r/tencent_190DA969DF79232C4E2FA681510C3E365108@qq.com
[2] git://git.kernel.org/pub/scm/linux/kernel/git/vdubeyko/hfs.git
next prev parent reply other threads:[~2026-12-01 22:18 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-01 13:34 [PATCH 0/3] fs: return ERR_PTR() from iget_locked() and friends Konstantin Adzer
2026-12-01 13:06 ` [PATCH 1/3] fuse: return ERR_PTR() from fuse_iget() Konstantin Adzer
2026-12-01 13:06 ` [PATCH 2/3] hfs: return ERR_PTR() from hfs_iget() Konstantin Adzer
2026-12-01 22:18 ` Viacheslav Dubeyko [this message]
2026-12-01 13:09 ` [PATCH 3/3] fs: return ERR_PTR() from iget_locked() and friends Konstantin Adzer
2026-12-01 16:09 ` [PATCH 0/3] " Jan Harkes
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=98eeb224a2bedd951956437ecf83a8e183bb3a20.camel@dubeyko.com \
--to=slava@dubeyko.com \
--cc=brauner@kernel.org \
--cc=info@massivetech.ru \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--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
all inboxes | Powered by JetHome®