Commit ce181ccd authored by Sergey Senozhatsky's avatar Sergey Senozhatsky Committed by Tong Tiangen
Browse files

zram: free secondary algorithms names

stable inclusion
from stable-v6.6.57
commit 6272936fd242ca1f784c3e21596dfb3859dff276
category: bugfix
bugzilla: https://gitee.com/src-openeuler/kernel/issues/IAYRI0
CVE: CVE-2024-50064

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=6272936fd242ca1f784c3e21596dfb3859dff276

--------------------------------

[ Upstream commit 684826f8271ad97580b138b9ffd462005e470b99 ]

We need to kfree() secondary algorithms names when reset zram device that
had multi-streams, otherwise we leak memory.

[senozhatsky@chromium.org: kfree(NULL) is legal]
  Link: https://lkml.kernel.org/r/20240917013021.868769-1-senozhatsky@chromium.org
Link: https://lkml.kernel.org/r/20240911025600.3681789-1-senozhatsky@chromium.org


Fixes: 001d9273 ("zram: add recompression algorithm sysfs knob")
Signed-off-by: default avatarSergey Senozhatsky <senozhatsky@chromium.org>
Cc: Minchan Kim <minchan@kernel.org>
Cc: <stable@vger.kernel.org>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
parent 351ec151
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -2130,6 +2130,11 @@ static void zram_destroy_comps(struct zram *zram)
		zcomp_destroy(comp);
		zram->num_active_comps--;
	}

	for (prio = ZRAM_SECONDARY_COMP; prio < ZRAM_MAX_COMPS; prio++) {
		kfree(zram->comp_algs[prio]);
		zram->comp_algs[prio] = NULL;
	}
}

static void zram_reset_device(struct zram *zram)