mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Luis Henriques <luis.henriques@canonical.com>
To: Minchan Kim <minchan@kernel.org>, Nitin Gupta <ngupta@vflare.org>
Cc: Sergey Senozhatsky <sergey.senozhatsky.work@gmail.com>,
	linux-kernel@vger.kernel.org
Subject: [PATCH] zram: fix possible use after free in zcomp_create()
Date: Mon,  7 Sep 2015 11:33:53 +0100	[thread overview]
Message-ID: <1441622033-8358-1-git-send-email-luis.henriques@canonical.com> (raw)

zcomp_create() verifies the success of zcomp_strm_{multi,siggle}_create()
through comp->stream, which can potentially be pointing to memory that was
freed if these functions returned an error.

Fixes: beca3ec71fe5 ("zram: add multi stream functionality")
Cc: stable@vger.kernel.org
Signed-off-by: Luis Henriques <luis.henriques@canonical.com>
---
 drivers/block/zram/zcomp.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/block/zram/zcomp.c b/drivers/block/zram/zcomp.c
index 965d1afb0eaa..f3db8158e172 100644
--- a/drivers/block/zram/zcomp.c
+++ b/drivers/block/zram/zcomp.c
@@ -212,6 +212,7 @@ static int zcomp_strm_multi_create(struct zcomp *comp, int max_strm)
 	zstrm = zcomp_strm_alloc(comp);
 	if (!zstrm) {
 		kfree(zs);
+		comp->stream = NULL;
 		return -ENOMEM;
 	}
 	list_add(&zstrm->list, &zs->idle_strm);
@@ -262,6 +263,7 @@ static int zcomp_strm_single_create(struct zcomp *comp)
 	zs->zstrm = zcomp_strm_alloc(comp);
 	if (!zs->zstrm) {
 		kfree(zs);
+		comp->stream = NULL;
 		return -ENOMEM;
 	}
 	return 0;

             reply	other threads:[~2015-09-07 10:34 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-09-07 10:33 Luis Henriques [this message]
2015-09-07 11:11 ` Sergey Senozhatsky
2015-09-07 12:53   ` Luis Henriques
2015-09-07 13:33     ` Sergey Senozhatsky
2015-09-07 14:11       ` Luis Henriques
2015-09-07 14:13       ` [PATCH v2] " Luis Henriques
2015-09-07 23:59         ` Sergey Senozhatsky
2015-09-08  1:07         ` Minchan Kim
2015-09-08  1:20           ` Sergey Senozhatsky
2015-09-08  1:34             ` Minchan Kim
2015-09-08  9:39               ` [PATCH v3] " Luis Henriques
2015-09-08  9:56                 ` Sergey Senozhatsky
2015-09-08 10:27                   ` Sergey Senozhatsky
2015-09-08 13:35                 ` Minchan Kim

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=1441622033-8358-1-git-send-email-luis.henriques@canonical.com \
    --to=luis.henriques@canonical.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=minchan@kernel.org \
    --cc=ngupta@vflare.org \
    --cc=sergey.senozhatsky.work@gmail.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®