mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Colin King <colin.king@canonical.com>
To: Miklos Szeredi <mszeredi@redhat.com>, linux-unionfs@vger.kernel.org
Cc: kernel-janitors@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH] ovl: fix null pointer dereference on ofs allocation failure.
Date: Thu,  9 Nov 2017 17:47:51 +0000	[thread overview]
Message-ID: <20171109174751.11683-1-colin.king@canonical.com> (raw)

From: Colin Ian King <colin.king@canonical.com>

The current error exit path when ofs fails to allocate jumps
to clean-up code that calls ovl_free_fs resulting in a null pointer
dereference on the null ovl pointer.  Fix this by simply returning
with the -ENOMEM status in err.

Detected by CoverityScan, CID#1461284 ("Dereference after null check")

Fixes: 4f3bf9de9eac ("ovl: factor out ovl_free_fs() helper")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
 fs/overlayfs/super.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/overlayfs/super.c b/fs/overlayfs/super.c
index 708afec913ac..8258a194695b 100644
--- a/fs/overlayfs/super.c
+++ b/fs/overlayfs/super.c
@@ -1154,7 +1154,7 @@ static int ovl_fill_super(struct super_block *sb, void *data, int silent)
 	err = -ENOMEM;
 	ofs = kzalloc(sizeof(struct ovl_fs), GFP_KERNEL);
 	if (!ofs)
-		goto out_err;
+		return err;
 
 	ofs->creator_cred = cred = prepare_creds();
 	if (!cred)
-- 
2.14.1

             reply	other threads:[~2017-11-09 17:47 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-11-09 17:47 Colin King [this message]
2017-11-10  8:54 ` Miklos Szeredi

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=20171109174751.11683-1-colin.king@canonical.com \
    --to=colin.king@canonical.com \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-unionfs@vger.kernel.org \
    --cc=mszeredi@redhat.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®