From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4D566606A325 for ; Tue, 1 Dec 2026 11:22:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=XaTZZ31g; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=FQhUV291 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: MIME-Version:Message-ID:Date:Subject:Cc:To:From:Reply-To:Content-Type: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Unsubscribe-Post:List-Owner; bh=5saVQ1i+xzeRoNpsGs1ckhPLKGUaOJRSXitSEJTNo3o=; b=XaTZZ31gPJmf/LLTW0Z7CcT/Yi jck64LYPDuaKCdeSwNRwsZjtP/eVhAz+E2rNCwFd0t8PeVZK6MCDi0zkpEm94xMgiabQKIrCmqU65 Zaqk7m3eaIlsr44rAmEUnFrqQzgVthinKIn5pXGNEM8RwJ/H6kFwwl1w7lp+snkIf/eGuY7472jh3 UZbe2MyTj/1cmb7O3dU6WXAk1o2OT9xg8rZuD/KtR5u6G2X3cfDAo42gngQxDCiTiJctQMyhTbZZF f6KYKxc9ZjXloxkRT4jLi5NdVDG+MDeY4fJkvcEGRXmgKbQVpzrpHxfJN1iwc4Yd/+W3sCtfZ2+wH /YUpeYvw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.100.1 #2 (Red Hat Linux)) id 1xYLw8-00000007Xmo-0N5C; Tue, 01 Dec 2026 11:22:16 +0000 Received: from sea.source.kernel.org ([2600:3c0a:e001:78e:0:1991:8:25]) by bombadil.infradead.org with esmtps (Exim 4.100.1 #2 (Red Hat Linux)) id 1xYLw5-00000007Xk8-2KFW for linux-arm-kernel@lists.infradead.org; Tue, 01 Dec 2026 11:22:14 +0000 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) by sea.source.kernel.org (Postfix) with ESMTP id EC33140236; Tue, 1 Dec 2026 11:22:12 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id ED5651F0089A; Tue, 1 Dec 2026 11:22:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796124132; bh=5saVQ1i+xzeRoNpsGs1ckhPLKGUaOJRSXitSEJTNo3o=; h=From:To:Cc:Subject:Date; b=FQhUV291J4yLz9Tts1vJM8wwo9lilE8y6SHVMb34xtKIvBtF1wpaISnt3CD2yQCM6 /uBy6CHOZR4kLOcaFU9jKh3kCsn+m1lmUNiRT0elaq05lioVXmAkEiKXC7YsrjyPFI S5Z1jUnjRFLBanrkD94pmDAkadI6QxbfssTRpF+vET56LhW2ws0FDZePMBZZq1iRHO bkNffPZu6l3R0xUYF0N7YU9E/7VDYZy583L0334D/vK76AcqwPYkAMdhkUOfycPNPg bB7a/olAhqwoeRDkazBYbP5tt5p7QO3bjsmjhOrSuGcIgpRg+n5AQVSy7xOjgKixUL QWz2BMUjASfmg== From: Thorsten Blum To: Thorsten Blum , Herbert Xu , "David S. Miller" , Nicolas Ferre , Alexandre Belloni , Claudiu Beznea Cc: linux-crypto@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH] crypto: atmel-ecc - use guards to release i2c_list_lock Date: Tue, 1 Dec 2026 12:21:38 +0100 Message-ID: <20261201112137.1550383-2-blum@kernel.org> X-Mailer: git-send-email 2.56.1 X-Archived-By: MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=2660; i=blum@kernel.org; h=from:subject; bh=NvgDeLoiro2PBIp/aIHHDuEdRAEl+LQUSOrqGo/MUyo=; b=owGbwMvMwCUWt7pQ4caZUj3G02pJDNl8aw9+vj5Zf6pI6qVJWr8098cbtq1QqzpvIvgx+9zCl 2d4N1T1d5SyMIhxMciKKbI8mPVjhm9pTeUmk4idMHNYmUCGMHBxCsBEbiUz/E+ZNd8i77bW24rr W7YZb3tQJa5lGVCj81F03d1LPErNJrkM/0xTOLXPmOx5/n/C4hMHlm36Oz25tlKwcH/rtYp5Ces N0zgA X-Developer-Key: i=blum@kernel.org; a=openpgp; fpr=1D60735E8AEF3BE473B69D84733678FD8DFEEAD4 Content-Transfer-Encoding: 8bit X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" X-Spam-Status: No, score=-18.9 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=4.0.1 X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on aws-us-west-2-korg-listserv-alma10-1 Use guard(spinlock) and scoped guards to release i2c_list_lock automatically. No functional change. Signed-off-by: Thorsten Blum --- drivers/crypto/atmel-ecc.c | 25 +++++++++---------------- 1 file changed, 9 insertions(+), 16 deletions(-) diff --git a/drivers/crypto/atmel-ecc.c b/drivers/crypto/atmel-ecc.c index b538e818a26f..c6d14854128a 100644 --- a/drivers/crypto/atmel-ecc.c +++ b/drivers/crypto/atmel-ecc.c @@ -17,6 +17,7 @@ #include #include #include +#include #include #include #include @@ -194,12 +195,10 @@ static struct i2c_client *atmel_ecc_i2c_client_alloc(void) int min_tfm_cnt = INT_MAX; int tfm_cnt; - spin_lock(&driver_data.i2c_list_lock); + guard(spinlock)(&driver_data.i2c_list_lock); - if (list_empty(&driver_data.i2c_client_list)) { - spin_unlock(&driver_data.i2c_list_lock); + if (list_empty(&driver_data.i2c_client_list)) return ERR_PTR(-ENODEV); - } list_for_each_entry(i2c_priv, &driver_data.i2c_client_list, i2c_client_list_node) { @@ -217,8 +216,6 @@ static struct i2c_client *atmel_ecc_i2c_client_alloc(void) client = min_i2c_priv->client; } - spin_unlock(&driver_data.i2c_list_lock); - return client; } @@ -299,16 +296,13 @@ static int atmel_ecc_probe(struct i2c_client *client) i2c_priv = i2c_get_clientdata(client); - spin_lock(&driver_data.i2c_list_lock); - list_add_tail(&i2c_priv->i2c_client_list_node, - &driver_data.i2c_client_list); - spin_unlock(&driver_data.i2c_list_lock); + scoped_guard(spinlock, &driver_data.i2c_list_lock) + list_add_tail(&i2c_priv->i2c_client_list_node, &driver_data.i2c_client_list); ret = crypto_register_kpp(&atmel_ecdh_nist_p256); if (ret) { - spin_lock(&driver_data.i2c_list_lock); - list_del(&i2c_priv->i2c_client_list_node); - spin_unlock(&driver_data.i2c_list_lock); + scoped_guard(spinlock, &driver_data.i2c_list_lock) + list_del(&i2c_priv->i2c_client_list_node); dev_err(&client->dev, "%s alg registration failed\n", atmel_ecdh_nist_p256.base.cra_driver_name); @@ -339,9 +333,8 @@ static void atmel_ecc_remove(struct i2c_client *client) crypto_unregister_kpp(&atmel_ecdh_nist_p256); - spin_lock(&driver_data.i2c_list_lock); - list_del(&i2c_priv->i2c_client_list_node); - spin_unlock(&driver_data.i2c_list_lock); + scoped_guard(spinlock, &driver_data.i2c_list_lock) + list_del(&i2c_priv->i2c_client_list_node); } static const struct of_device_id atmel_ecc_dt_ids[] = {