[PATCH v14 24/26] mm: zswap: Consistently use IS_ERR_OR_NULL() to check acomp_ctx resources.

Kanchana P Sridhar posted 26 patches 1 week, 6 days ago
[PATCH v14 24/26] mm: zswap: Consistently use IS_ERR_OR_NULL() to check acomp_ctx resources.
Posted by Kanchana P Sridhar 1 week, 6 days ago
Use IS_ERR_OR_NULL() in zswap_cpu_comp_prepare() to check for valid
acomp/req, making it consistent with acomp_ctx_dealloc().

Signed-off-by: Kanchana P Sridhar <kanchana.p.sridhar@intel.com>
Acked-by: Yosry Ahmed <yosry.ahmed@linux.dev>
---
 mm/zswap.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/mm/zswap.c b/mm/zswap.c
index 9480d54264e4..0d56390342b7 100644
--- a/mm/zswap.c
+++ b/mm/zswap.c
@@ -783,7 +783,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)) {
 		pr_err("could not alloc crypto acomp %s : %ld\n",
 				pool->tfm_name, PTR_ERR(acomp_ctx->acomp));
 		ret = PTR_ERR(acomp_ctx->acomp);
@@ -791,7 +791,7 @@ static int zswap_cpu_comp_prepare(unsigned int cpu, struct hlist_node *node)
 	}
 
 	acomp_ctx->req = acomp_request_alloc(acomp_ctx->acomp);
-	if (!acomp_ctx->req) {
+	if (IS_ERR_OR_NULL(acomp_ctx->req)) {
 		pr_err("could not alloc crypto acomp_request %s\n",
 		       pool->tfm_name);
 		goto fail;
-- 
2.27.0
Re: [PATCH v14 24/26] mm: zswap: Consistently use IS_ERR_OR_NULL() to check acomp_ctx resources.
Posted by Nhat Pham 1 week ago
On Sat, Jan 24, 2026 at 7:36 PM Kanchana P Sridhar
<kanchana.p.sridhar@intel.com> wrote:
>
> Use IS_ERR_OR_NULL() in zswap_cpu_comp_prepare() to check for valid
> acomp/req, making it consistent with acomp_ctx_dealloc().
>
> Signed-off-by: Kanchana P Sridhar <kanchana.p.sridhar@intel.com>
> Acked-by: Yosry Ahmed <yosry.ahmed@linux.dev>

LGTM. I wonder if this is technically a fix?

Also, considering submitting this separately if the patch series stall
- so that you don't have to carry one extra patch around every time :)

Anyway:
Acked-by: Nhat Pham <nphamcs@gmail.com>
RE: [PATCH v14 24/26] mm: zswap: Consistently use IS_ERR_OR_NULL() to check acomp_ctx resources.
Posted by Sridhar, Kanchana P 1 week ago
> -----Original Message-----
> From: Nhat Pham <nphamcs@gmail.com>
> Sent: Friday, January 30, 2026 3:53 PM
> To: Sridhar, Kanchana P <kanchana.p.sridhar@intel.com>
> Cc: linux-kernel@vger.kernel.org; linux-mm@kvack.org;
> hannes@cmpxchg.org; yosry.ahmed@linux.dev; chengming.zhou@linux.dev;
> usamaarif642@gmail.com; ryan.roberts@arm.com; 21cnbao@gmail.com;
> ying.huang@linux.alibaba.com; akpm@linux-foundation.org;
> senozhatsky@chromium.org; sj@kernel.org; kasong@tencent.com; linux-
> crypto@vger.kernel.org; herbert@gondor.apana.org.au;
> davem@davemloft.net; clabbe@baylibre.com; ardb@kernel.org;
> ebiggers@google.com; surenb@google.com; Accardi, Kristen C
> <kristen.c.accardi@intel.com>; Gomes, Vinicius <vinicius.gomes@intel.com>;
> Cabiddu, Giovanni <giovanni.cabiddu@intel.com>; Feghali, Wajdi K
> <wajdi.k.feghali@intel.com>
> Subject: Re: [PATCH v14 24/26] mm: zswap: Consistently use
> IS_ERR_OR_NULL() to check acomp_ctx resources.
> 
> On Sat, Jan 24, 2026 at 7:36 PM Kanchana P Sridhar
> <kanchana.p.sridhar@intel.com> wrote:
> >
> > Use IS_ERR_OR_NULL() in zswap_cpu_comp_prepare() to check for valid
> > acomp/req, making it consistent with acomp_ctx_dealloc().
> >
> > Signed-off-by: Kanchana P Sridhar <kanchana.p.sridhar@intel.com>
> > Acked-by: Yosry Ahmed <yosry.ahmed@linux.dev>
> 
> LGTM. I wonder if this is technically a fix?

Hi Nhat,

Thanks for the review comments and for the Ack! 

As to whether this is technically a fix: I think the answer is "not really",
because:

1) The failure handling has been consolidated to acomp_ctx_dealloc().
2) acomp_ctx_dealloc() replaces the existing zswap_cpu_comp_dead(),
    which uses the same checks with IS_ERR_OR_NULL() for the
    acomp_ctx->acomp and acomp_ctx->req.
3) Hence, this patch brings the error condition checks for these two
     acomp_ctx members' allocation to be consistent with (1) and (2).

So I suppose this is a consistency change rather than a fix. Please
correct me if I am wrong.

> 
> Also, considering submitting this separately if the patch series stall
> - so that you don't have to carry one extra patch around every time :)

Sure, thanks for the suggestion.

I would appreciate it if yourself and Yosry can review the other zswap
related patches in this series. I have addressed all but one v13 comment,
as mentioned in the cover letter in the "v14 Performance Summary"
section.

> 
> Anyway:
> Acked-by: Nhat Pham <nphamcs@gmail.com>

Thanks!
Kanchana