mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Viacheslav Dubeyko <Slava.Dubeyko@ibm.com>
To: "ethantidmore06@gmail.com" <ethantidmore06@gmail.com>,
	"glaubitz@physik.fu-berlin.de" <glaubitz@physik.fu-berlin.de>,
	"frank.li@vivo.com" <frank.li@vivo.com>,
	"slava@dubeyko.com" <slava@dubeyko.com>
Cc: "linux-fsdevel@vger.kernel.org" <linux-fsdevel@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re:  [PATCH] hfsplus: Fix error pointer dereference
Date: Wed, 18 Feb 2026 20:44:12 +0000	[thread overview]
Message-ID: <4c416deeaa61d93abf3a825cbe15eba9e1e23964.camel@ibm.com> (raw)
In-Reply-To: <20260218193305.11316-1-ethantidmore06@gmail.com>

On Wed, 2026-02-18 at 13:33 -0600, Ethan Tidmore wrote:
> The function hfs_bnode_find() can return an error pointer and is not
> checked for one. Add error pointer check.
> 

If we take a look into the hfs_brec_update_parent(), then we can see that parent
node is already found as valid node [1]. And new_node has been prepared with
parent node set in hfs_bnode_split() [2]. It's highly not possible to have not
valid pointer for this call. I don't think that we really need this check.

Thanks,
Slava.

> Detected by Smatch:
> fs/hfsplus/brec.c:441 hfs_brec_update_parent() error: 
> 'fd->bnode' dereferencing possible ERR_PTR()
> 
> Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
> Signed-off-by: Ethan Tidmore <ethantidmore06@gmail.com>
> ---
>  fs/hfsplus/brec.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/fs/hfsplus/brec.c b/fs/hfsplus/brec.c
> index 6796c1a80e99..efe79a8f1d98 100644
> --- a/fs/hfsplus/brec.c
> +++ b/fs/hfsplus/brec.c
> @@ -434,6 +434,9 @@ static int hfs_brec_update_parent(struct hfs_find_data *fd)
>  			new_node->parent = tree->root;
>  		}
>  		fd->bnode = hfs_bnode_find(tree, new_node->parent);
> +		if (IS_ERR(fd->bnode))
> +			return PTR_ERR(fd->bnode);
> +
>  		/* create index key and entry */
>  		hfs_bnode_read_key(new_node, fd->search_key, 14);
>  		cnid = cpu_to_be32(new_node->this);

[1] https://elixir.bootlin.com/linux/v6.19-rc5/source/fs/hfsplus/brec.c#L371
[2] https://elixir.bootlin.com/linux/v6.19-rc5/source/fs/hfsplus/brec.c#L253

      reply	other threads:[~2026-02-18 20:44 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-02-18 19:33 Ethan Tidmore
2026-02-18 20:44 ` Viacheslav Dubeyko [this message]

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=4c416deeaa61d93abf3a825cbe15eba9e1e23964.camel@ibm.com \
    --to=slava.dubeyko@ibm.com \
    --cc=ethantidmore06@gmail.com \
    --cc=frank.li@vivo.com \
    --cc=glaubitz@physik.fu-berlin.de \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=slava@dubeyko.com \
    /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®