From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BF81939B96B for ; Mon, 16 Mar 2026 15:09:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773673751; cv=none; b=r/gCS+ZLeHQO830C8IcNABhE8YDdAPqWBZ1+grM+gMGHM43+IqYCMeiz7r5DpZyqi336z3rR3eCZny3nVx66zs0w0icbAoY8C6osgZIsHV6vQsg0JwocXfPFnBUBjzxIHaMCOyyyfsRVyrDBAhq3LyEpRvrpHJqF+Z6MWFq+hOo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773673751; c=relaxed/simple; bh=HPF/v3WoPFEV24nIvaRDll4p1q2/19OPsfrmQMWB690=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=gDUNWHIGRzBPr7Si/HjkdY6kz7Ng58CkeXy2bSO+adfd/Hx2hYhV0w9gpVO4qF677ceGGWGMQmIChhjLT7/Rlh8yA0Pw+sti5fFRDHFzd3LibijXkMJ/m9qJ7SdyEi4jAgbtJSW7CO2Z7Cm+EyeR15dtnbED230ZA61MeUy1mBU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=KfDufog2; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="KfDufog2" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 36DEEC19425; Mon, 16 Mar 2026 15:09:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1773673751; bh=HPF/v3WoPFEV24nIvaRDll4p1q2/19OPsfrmQMWB690=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=KfDufog2r8xXqjzM5tsu3ZcXwn9SVxnsslaBKPpbuBvGc8Re/xOPVzbund88z5qJy z9YxlOpKgdu7FTofKrrMAcrvPe5emwpcKD4iJjy0SvmZqMuRKNMGUnDRlHbrZ1gcJs Gxaq+Mqby7cMoF6i6uIKct5/SzpVhC8p/h5KaM1V6LaKbQpSvAccSmtSqOYaW41V9i Q89Ya7EdrTLkGvPmDHbCKpWybBGFzJnkbChMSMEwVQhifxhYWKgBlEYL/PrPz6aZj2 rroC4xacQGUPW5DvvUpM+bh2N6p2FNLiFnZhpMDLyqpHgbJW4RkNx+leuqx1BwFHtY n82jE/3J6GUvA== Date: Mon, 16 Mar 2026 15:09:09 +0000 From: Yosry Ahmed To: "Kanchana P. Sridhar" Cc: Andrew Morton , 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 Message-ID: References: <20260314051632.17931-1-kanchanapsridhar2026@gmail.com> <20260314171150.fd6a80a8f51a5390144d20d6@linux-foundation.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: 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.