From: Yosry Ahmed <yosry@kernel.org>
To: "Kanchana P. Sridhar" <kanchanapsridhar2026@gmail.com>
Cc: Andrew Morton <akpm@linux-foundation.org>,
hannes@cmpxchg.org, nphamcs@gmail.com, chengming.zhou@linux.dev,
linux-mm@kvack.org, linux-kernel@vger.kernel.org,
herbert@gondor.apana.org.au, senozhatsky@chromium.org
Subject: Re: [PATCH 0/2] zswap pool per-CPU acomp_ctx simplifications
Date: Mon, 16 Mar 2026 15:09:09 +0000 [thread overview]
Message-ID: <abgc5cn8Co9ft0Wr@google.com> (raw)
In-Reply-To: <abgbx0YXbxu2mAHU@google.com>
On Mon, Mar 16, 2026 at 03:06:32PM +0000, Yosry Ahmed wrote:
> > > > @@ -786,7 +786,7 @@ static int zswap_cpu_comp_prepare(unsigned int cpu, struct hlist_node *node)
> > > > return ret;
> > > >
> > > > acomp_ctx->acomp = crypto_alloc_acomp_node(pool->tfm_name, 0, 0, cpu_to_node(cpu));
> > > > - if (IS_ERR(acomp_ctx->acomp)) {
> > > > + if (IS_ERR_OR_NULL(acomp_ctx->acomp)) {
> > > Does crypto_alloc_acomp_node() ever return NULL?
> > > Looking at the error handling just below this check, if this were to
> > > actually return NULL, PTR_ERR(NULL) evaluates to 0. This would cause
> > > the function to incorrectly return 0 (success) instead of an error code,
> > > hiding the allocation failure.
> >
> > This is a good catch. Just to provide context, this patch was
> > introduced based on Yosry's earlier comments in [1].
> >
> > [1]: https://patchwork.kernel.org/comment/26282128/
> >
> > crypto_alloc_acomp_node() currently does not return NULL. However, it
> > could, in future.
> > Since the rest of zswap_cpu_comp_prepare() dereferences
> > acomp_ctx->acomp, it depends on whether we want to future-proof the
> > code to handle a possible eventuality of crypto_alloc_acomp_node()
> > returning NULL.
>
> Hmm upon revisiting this, I think keeping this as IS_ERR() here is a
> better documentation for the API, and the incossitency between this code
> and acomp_ctx_dealloc() is arguably documenting that the function can
> only return an ERR, but it can also be NULL-initialized by zswap.
Also, sorry for leading you astray in the first place. Looking at this
initially I thought the inconsistency was confusing, but looking at it
with fresh eyes I think it better documents the API and the different
callsites.
next prev parent reply other threads:[~2026-03-16 15:09 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-14 5:16 [PATCH 0/2] zswap pool per-CPU acomp_ctx simplifications Kanchana P. Sridhar
2026-03-14 5:16 ` [PATCH 1/2] mm: zswap: Tie per-CPU acomp_ctx lifetime to the pool Kanchana P. Sridhar
2026-03-16 15:07 ` Yosry Ahmed
2026-03-16 18:21 ` Kanchana P. Sridhar
2026-03-14 5:16 ` [PATCH 2/2] mm: zswap: Consistently use IS_ERR_OR_NULL() to check acomp_ctx resources Kanchana P. Sridhar
2026-03-15 0:11 ` [PATCH 0/2] zswap pool per-CPU acomp_ctx simplifications Andrew Morton
2026-03-15 3:30 ` Kanchana P. Sridhar
2026-03-16 15:06 ` Yosry Ahmed
2026-03-16 15:09 ` Yosry Ahmed [this message]
2026-03-16 18:22 ` Kanchana P. Sridhar
2026-03-16 18:20 ` Kanchana P. Sridhar
2026-03-16 18:30 ` Yosry Ahmed
2026-03-16 19:21 ` Kanchana P. Sridhar
2026-03-16 19:24 ` Yosry Ahmed
2026-03-16 19:31 ` Kanchana P. Sridhar
2026-03-16 19:32 ` Yosry Ahmed
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=abgc5cn8Co9ft0Wr@google.com \
--to=yosry@kernel.org \
--cc=akpm@linux-foundation.org \
--cc=chengming.zhou@linux.dev \
--cc=hannes@cmpxchg.org \
--cc=herbert@gondor.apana.org.au \
--cc=kanchanapsridhar2026@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=nphamcs@gmail.com \
--cc=senozhatsky@chromium.org \
/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