Re: [PATCH v2 1/5] zram: fix early release of global cdict/ddict in per-CPU error path
From: haoqin huang
Date: Tue Jul 28 2026 - 23:34:59 EST
On Wed, Jul 29, 2026 at 8:34 AM Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> wrote:
>
> On Tue, 28 Jul 2026 17:29:31 +0800 Haoqin Huang <haoqinhuang7@xxxxxxxxx> wrote:
>
> > zstd_setup_params() creates global cdict and ddict stored in
> > params->drv_data, shared across all per-CPU contexts. The per-CPU
> > zstd_create() error path called zstd_release_params(), which freed
> > those globally-shared objects. While the drv_data=NULL guard in
> > zstd_release_params() prevents a double-free on the init failure
> > path, this is still a layering violation: a per-CPU callback should
> > only clean up its own context, not release resources owned by the
> > compression lifecycle (zcomp_init / zcomp_destroy).
> >
> > Fix by removing zstd_release_params() from the per-CPU error path
> > and replacing it with only zstd_destroy(), which properly cleans
> > up the per-CPU context without touching the global params->drv_data.
>
> Thanks. A [0/N] cover letter would be appropriate.
>
>
> Do any of these changes have userspace-visible runtime effects? If so,
> please changelog these in full detail. If not, a statement (in the
> [0/N]!) telling us this would be helpful.
>
That's fair, these are fairly small changes so I skipped the cover
letter. I'll add one with a changelog in v3.
The changes don't have any userspace-visible runtime effects.
>
> AI review might have found a few things, about half of them
> pre-existing (zram/zcomp):
>
> https://sashiko.dev/#/patchset/20260728092935.31139-1-haoqinhuang7@xxxxxxxxx
>
>
I took a look at the AI review and there are a few things I can clean
up in the next version — I'll fold those into v3 as well.
Thanks.