From: Phillip Lougher <phillip@squashfs.org.uk>
To: scott_gzh@163.com
Cc: linux-kernel@vger.kernel.org, Scott GUO <scottzhguo@tencent.com>
Subject: Re: [PATCH] squashfs: Avoid mem leak in squashfs_fill_super
Date: Mon, 11 Aug 2025 23:35:26 +0100 [thread overview]
Message-ID: <2156fc8a-a43b-4986-8537-d1d530821dbf@squashfs.org.uk> (raw)
In-Reply-To: <20250811061921.3807353-1-scott_gzh@163.com>
On 11/08/2025 07:19, scott_gzh@163.com wrote:
> From: Scott GUO <scottzhguo@tencent.com>
>
> If sb_min_blocksize returns 0, -EINVAL was returned without freeing
> sb->s_fs_info, causing mem leak.
>
> Fix it by goto failed_mount.
>
Thanks for spotting this, but, NACK to the patch.
A better fix is to call sb_min_blocksize and check the
return result before the memory is allocated.
Phillip
> Fixes: 734aa85390ea ("Squashfs: check return result of sb_min_blocksize")
> Signed-off-by: Scott GUO <scottzhguo@tencent.com>
> ---
> fs/squashfs/super.c | 6 +++---
> 1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/fs/squashfs/super.c b/fs/squashfs/super.c
> index 992ea0e37257..7d501083b2e3 100644
> --- a/fs/squashfs/super.c
> +++ b/fs/squashfs/super.c
> @@ -201,10 +201,12 @@ static int squashfs_fill_super(struct super_block *sb, struct fs_context *fc)
>
> msblk->panic_on_errors = (opts->errors == Opt_errors_panic);
>
> + err = -EINVAL;
> +
> msblk->devblksize = sb_min_blocksize(sb, SQUASHFS_DEVBLK_SIZE);
> if (!msblk->devblksize) {
> errorf(fc, "squashfs: unable to set blocksize\n");
> - return -EINVAL;
> + goto failed_mount;
> }
>
> msblk->devblksize_log2 = ffz(~msblk->devblksize);
> @@ -227,8 +229,6 @@ static int squashfs_fill_super(struct super_block *sb, struct fs_context *fc)
> goto failed_mount;
> }
>
> - err = -EINVAL;
> -
> /* Check it is a SQUASHFS superblock */
> sb->s_magic = le32_to_cpu(sblk->s_magic);
> if (sb->s_magic != SQUASHFS_MAGIC) {
next prev parent reply other threads:[~2025-08-11 22:43 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-08-11 6:19 scott_gzh
2025-08-11 7:02 ` Markus Elfring
2025-08-12 2:11 ` Scott Guo
2025-08-12 8:18 ` Dan Carpenter
2025-08-12 8:38 ` Markus Elfring
2025-08-12 9:20 ` Dan Carpenter
2025-08-11 22:35 ` Phillip Lougher [this message]
2025-08-12 2:11 ` [PATCH] " Scott Guo
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=2156fc8a-a43b-4986-8537-d1d530821dbf@squashfs.org.uk \
--to=phillip@squashfs.org.uk \
--cc=linux-kernel@vger.kernel.org \
--cc=scott_gzh@163.com \
--cc=scottzhguo@tencent.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®