mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Peng Hao <flyingpenghao@gmail.com>
To: phillip@squashfs.org.uk
Cc: linux-kernel@vger.kernel.org
Subject: [PATCH]  fs/squashfs: handle possible null pointer
Date: Tue, 21 Dec 2021 10:03:47 +0800	[thread overview]
Message-ID: <20211221020347.46021-1-flyingpeng@tencent.com> (raw)

 in squashfs_fill_super:

        msblk->decompressor = supported_squashfs_filesystem(
                        fc,
                        le16_to_cpu(sblk->s_major),
                        le16_to_cpu(sblk->s_minor),
                        le16_to_cpu(sblk->compression));
        if (msblk->decompressor == NULL)
                goto failed_mount;
        ...

failed_mount:
	...
	squashfs_decompressor_destroy(msblk);

in squashfs_decompressor_destroy:
	if (stream) {
        	msblk->decompressor->free(stream->stream);
msblk->decompressor is NULL.

so add a judgment whether a null pointer.

Signed-off-by: Peng Hao <flyingpeng@tencent.com>
---
 fs/squashfs/decompressor_single.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/fs/squashfs/decompressor_single.c b/fs/squashfs/decompressor_single.c
index 4eb3d083d45e..a155452bbc54 100644
--- a/fs/squashfs/decompressor_single.c
+++ b/fs/squashfs/decompressor_single.c
@@ -54,7 +54,8 @@ void squashfs_decompressor_destroy(struct squashfs_sb_info *msblk)
 	struct squashfs_stream *stream = msblk->stream;
 
 	if (stream) {
-		msblk->decompressor->free(stream->stream);
+		if (msblk->decompressor)
+			msblk->decompressor->free(stream->stream);
 		kfree(stream);
 	}
 }
-- 
2.27.0


             reply	other threads:[~2021-12-21  2:05 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-12-21  2:03 Peng Hao [this message]
2021-12-22  1:38 ` Phillip Lougher

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=20211221020347.46021-1-flyingpeng@tencent.com \
    --to=flyingpenghao@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=phillip@squashfs.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®