From nobody Wed Apr 1 09:45:14 2026 Received: from mail-dl1-f49.google.com (mail-dl1-f49.google.com [74.125.82.49]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id F408237DEA9 for ; Tue, 31 Mar 2026 18:34:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=74.125.82.49 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774982048; cv=none; b=kdiRG2NO2Va2m5PLZe5prBffrtIYmyRrad2pM06tyzQlD9q6624Cpee78cAmLtdaqVNXv05zRb+D70Wcd8av3o9DF5o6bhJ1PuG5DMkEQwUwMZSfJMfpUvNk5mIT+0vdS6u+SOnuFXcjcy7Vzx8D40MVyZsItbebPOLTp2ct4Z0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774982048; c=relaxed/simple; bh=0MD/xBcN2w+qLvAUrmfPCI6CHkUmIcCnBbBCUTnDbow=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=LBWuLnqmFz4QteBn7yn8irp0GEoKGc0wgnRXrYkHAW7tfpcuwFgE5UKyUAWLSIu2XDK4aki+mYeeITjlelH0A+o3iownZDofqYcDXtoFTLxAJVzOmchcS/wMFaS0i9LU2R8Ya6Gj4SAcAxOTk5XwZGrQ6StlBe8oBIf7c7rtYlA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=LP0VEeuz; arc=none smtp.client-ip=74.125.82.49 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="LP0VEeuz" Received: by mail-dl1-f49.google.com with SMTP id a92af1059eb24-127380532eeso1299632c88.1 for ; Tue, 31 Mar 2026 11:34:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1774982046; x=1775586846; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=8Z9k6IBVmnZKroX7/272gWXi20ZJmLT8jW6F8/KWzUQ=; b=LP0VEeuzlniZdle2+azsEIiEXlDydu/GHJGTOIPv6PKH2Hz5DYwGF1LKkdVen8feYE BJC2LvdapyjJFUb6APrsK++Hv4vplCqK6ZhNOP57rkxVVi+hbDw89lof6QkR9CkvyR6F ukA89f6MGq6Yvi0uzyHegR8L0ifUPS/SLdFKoSDlgUmZqQ2YD7C40QbnWcVq4dhgi5j2 N06FDq0CxzOhf0K2TjP+Hyfokfsyr+LaSkSndggtXJpH3q+qUtTdmBTkbJlQXDYt8Qg7 HtgWoDDb0Ro0XhViF7lQ4Judo3RTsrFKrXrc6bhvpE/BIxwN37VHJU3rjdUp1ZL7vTr/ 2Dgw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1774982046; x=1775586846; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=8Z9k6IBVmnZKroX7/272gWXi20ZJmLT8jW6F8/KWzUQ=; b=oOAtsnGc8gyct9dFXj4zKcclYpomlNqze5m2yUkFhvvMXGt/MWe7EAtz+S/xdyCkOz 2VoDU94N5ts1I2zj8IH4KbGIPuWeUMsrXJ7lK4bG+vTQcsF3cIPlEWH3wcje41LKQ4Cg s/JwWjbWoLxWX3x9HIzDvxJ7FEq2O18qVts07mvQXUChHxZqfk38sRDmqZOou0j9bc06 BYAwgcndLXkfD4wDTZicmbO6VwOB8pO4XIFOSVSpQBGQvO6lHpKowBUceWSHu3gDBovV KHITSVCe0Q8SA9EKd6zXx2kQLsmjM9RCc/ecVbvFSvcINs1SowbSM9ovXKodPRHMcG7l IzPg== X-Forwarded-Encrypted: i=1; AJvYcCUyFTIzJzmccP6OoN8D66Zuy9q0rK1OjDoDyYMpKpE4BXoOBTINs2T6t0PuM5K7bhlaTEMHo9hOclrOes8=@vger.kernel.org X-Gm-Message-State: AOJu0Yw+iljKUqbJqX4sOg3aZZr4dr3F/4uJiYn737Z2+Pcsx0KIcQ1E ioDPMfEZSgFr9eOe/zhjddX0sYuUxcGHSCZqt1IjWqhMFIvKw50xX41R X-Gm-Gg: ATEYQzwlTYOQHIICfWFAUv+M7WPikSaVpiVdb+/a5qT8L4/k98E2JwLeOtoTthYXSFx xkUkkw20DJqz/b3n+wzBIm45Uqm2GROFyQGcWt+BN17gnlo1fOD1VxL0ssFpVUEDD8oV/DMykDs T6PqiJKzqMOQ1HaEZ/TamTp9pJ4Al7u/ZVPojcO7upoPrukD0g2anbAE19nfgdrZSxYOz/6jCkT UPF3Timv05Qy2pPZVl+LQJ1X4D1pzU15++x2r5cChA2AdJEFT/k3YVLX4UuDKUNWQQSf7c17bgq dAlgMrjQzGjKB/OnfLPbzq4p/3PserdWFuOuN77EylJncitx80/Fn/lOUdKP9u+P/T1rHvR/CCy KyyqDVwZHnuDzzmaGhktFs38hoL3A+9H4Z5rlYcisZrNdCMABWlFUqYO5AcXbBwxLRB5gjWnY05 3j3GvmUi+x5m/2cMGK0DuvIOHMnVCFCcrONwf3TGY8fbzVr8ui X-Received: by 2002:a05:7022:f697:b0:128:cedb:33ba with SMTP id a92af1059eb24-12be645523dmr398491c88.10.1774982046018; Tue, 31 Mar 2026 11:34:06 -0700 (PDT) Received: from penguin.lxd ([2601:647:6400:3ec0:216:3eff:fecd:e4ef]) by smtp.gmail.com with ESMTPSA id a92af1059eb24-12ac4a0fa8dsm7961271c88.15.2026.03.31.11.34.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 31 Mar 2026 11:34:05 -0700 (PDT) From: "Kanchana P. Sridhar" To: hannes@cmpxchg.org, yosry@kernel.org, nphamcs@gmail.com, chengming.zhou@linux.dev, akpm@linux-foundation.org, kanchanapsridhar2026@gmail.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org Cc: herbert@gondor.apana.org.au, senozhatsky@chromium.org Subject: [PATCH v3 1/2] mm: zswap: Remove redundant checks in zswap_cpu_comp_dead(). Date: Tue, 31 Mar 2026 11:33:50 -0700 Message-Id: <20260331183351.29844-2-kanchanapsridhar2026@gmail.com> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20260331183351.29844-1-kanchanapsridhar2026@gmail.com> References: <20260331183351.29844-1-kanchanapsridhar2026@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" There are presently redundant checks on the per-CPU acomp_ctx and it's "req" member in zswap_cpu_comp_dead(): redundant because they are inconsistent with zswap_pool_create() handling of failure in allocating the acomp_ctx, and with the expected NULL return value from the acomp_request_alloc() API when it fails to allocate an acomp_req. Fix these by converting to them to be NULL checks. Add comments in zswap_cpu_comp_prepare() clarifying the expected return values of the crypto_alloc_acomp_node() and acomp_request_alloc() API. Suggested-by: Yosry Ahmed Signed-off-by: Kanchana P. Sridhar Acked-by: Yosry Ahmed --- mm/zswap.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/mm/zswap.c b/mm/zswap.c index 4f2e652e8ad3..c59045b59ffe 100644 --- a/mm/zswap.c +++ b/mm/zswap.c @@ -749,6 +749,10 @@ static int zswap_cpu_comp_prepare(unsigned int cpu, st= ruct hlist_node *node) goto fail; } =20 + /* + * In case of an error, crypto_alloc_acomp_node() returns an + * error pointer, never NULL. + */ acomp =3D crypto_alloc_acomp_node(pool->tfm_name, 0, 0, cpu_to_node(cpu)); if (IS_ERR(acomp)) { pr_err("could not alloc crypto acomp %s : %pe\n", @@ -757,6 +761,7 @@ static int zswap_cpu_comp_prepare(unsigned int cpu, str= uct hlist_node *node) goto fail; } =20 + /* acomp_request_alloc() returns NULL in case of an error. */ req =3D acomp_request_alloc(acomp); if (!req) { pr_err("could not alloc crypto acomp_request %s\n", @@ -802,7 +807,7 @@ static int zswap_cpu_comp_dead(unsigned int cpu, struct= hlist_node *node) struct crypto_acomp *acomp; u8 *buffer; =20 - if (IS_ERR_OR_NULL(acomp_ctx)) + if (!acomp_ctx) return 0; =20 mutex_lock(&acomp_ctx->mutex); @@ -817,8 +822,11 @@ static int zswap_cpu_comp_dead(unsigned int cpu, struc= t hlist_node *node) /* * Do the actual freeing after releasing the mutex to avoid subtle * locking dependencies causing deadlocks. + * + * If there was an error in allocating @acomp_ctx->req, it + * would be set to NULL. */ - if (!IS_ERR_OR_NULL(req)) + if (req) acomp_request_free(req); if (!IS_ERR_OR_NULL(acomp)) crypto_free_acomp(acomp); --=20 2.39.5