linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] zram: fix possible use after free in zcomp_create()
@ 2015-09-07 10:33 Luis Henriques
  2015-09-07 11:11 ` Sergey Senozhatsky
  0 siblings, 1 reply; 14+ messages in thread
From: Luis Henriques @ 2015-09-07 10:33 UTC (permalink / raw)
  To: Minchan Kim, Nitin Gupta; +Cc: Sergey Senozhatsky, linux-kernel

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;

^ permalink raw reply related	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2015-09-08 13:35 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-09-07 10:33 [PATCH] zram: fix possible use after free in zcomp_create() Luis Henriques
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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).