From: "Marek Behún" <kabel@kernel.org>
To: Dan Carpenter <dan.carpenter@linaro.org>
Cc: Qu Wenruo <wqu@suse.com>, u-boot@lists.denx.de
Subject: Re: [PATCH] fs: btrfs: Prevent error pointer dereference in list_subvolums()
Date: Tue, 1 Aug 2023 11:05:11 +0200 [thread overview]
Message-ID: <20230801110355.6ec692e5@dellmb> (raw)
In-Reply-To: <35c4ef18-f928-47c2-9661-17641aed124a@moroto.mountain>
On Wed, 26 Jul 2023 09:59:04 +0300
Dan Carpenter <dan.carpenter@linaro.org> wrote:
> If btrfs_read_fs_root() fails with -ENOENT, then we go to the next
> entry. Fine. But if it fails for a different reason then we need
> to clean up and return an error code. In the current code it
> doesn't clean up but instead dereferences "root" and crashes.
>
> Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
> ---
> I didn't CC the btrfs mailing list. Perhaps, I should have?
>
> fs/btrfs/subvolume.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/fs/btrfs/subvolume.c b/fs/btrfs/subvolume.c
> index d446e7a2c418..68ca7e48e48e 100644
> --- a/fs/btrfs/subvolume.c
> +++ b/fs/btrfs/subvolume.c
> @@ -199,6 +199,7 @@ static int list_subvolums(struct btrfs_fs_info *fs_info)
> ret = PTR_ERR(root);
> if (ret == -ENOENT)
> goto next;
> + goto out;
> }
> ret = list_one_subvol(root, result);
> if (ret < 0)
Reviewed-by: Marek Behún <kabel@kernel.org>
nice catch :) Dan, I always wanted to ask, since I've seen many such
"nice catches" over different subsystems from you. Do you write some
tools to find these? Or do you use coccinelle, or something?
Marek
next prev parent reply other threads:[~2023-08-01 9:05 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-07-26 6:59 [PATCH] fs: btrfs: Prevent error pointer dereference in list_subvolums() Dan Carpenter
2023-08-01 9:05 ` Marek Behún [this message]
2023-08-01 11:13 ` Dan Carpenter
2023-08-01 9:06 ` Qu Wenruo
2023-08-09 1:40 ` Tom Rini
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=20230801110355.6ec692e5@dellmb \
--to=kabel@kernel.org \
--cc=dan.carpenter@linaro.org \
--cc=u-boot@lists.denx.de \
--cc=wqu@suse.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.