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 43A5B145348; Thu, 13 Feb 2025 14:51:03 +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=1739458264; cv=none; b=mnfL+iTULwD1BHK1PElUNl0Cd9Acdwn6aDYJ5Xad8Ku7Ln+QIq/VE0Hgh9RCjeFPYTd047HVKfXSMAKm5XeyR4o+WbjdiFnPU6o2Lkl31hZ4yiOj3rQOzo3aUx9GmhTpFia7wmouWB9ZndJUZofI+an9K4E9rWrBf/lwm++eo14= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1739458264; c=relaxed/simple; bh=piDIR7T8XbCRlnpLPjvigPVhC03vsGPHCmk9EOfUgG0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ZONr5l/ApV5fDFodONBu7tDgshptbBBRbArlHO7EOyb04R6WZBMAoGnNNtSHXT073ANaZCoZD32RiQSas7D3v9ihmdUlxySSlPMIkOmpe6jzNc3ccjUdm4+SN1sDErQb8D2wUkpOyWSXZdNJ1aaHnBW7j1l0v0h1xib/bRWVzS4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=WF+gYdyo; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="WF+gYdyo" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 44965C4CED1; Thu, 13 Feb 2025 14:51:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1739458263; bh=piDIR7T8XbCRlnpLPjvigPVhC03vsGPHCmk9EOfUgG0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=WF+gYdyosFJ5UaDI12Gs+2+fQRe7ApR3DxzPpwOJNbV4UToYaPsJmihhlSqd+u1zQ Koszda2T6eep73tAg5ICnL+02zywiIWZGYOHxiIs+HWSN2AgiwUgjnZijSeO6cY6J0 Zb3wEhIOYaaw80mmRK9QtE54kQHH75OZiV4JyzJU= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Bartosz Golaszewski , Neil Armstrong , Herbert Xu Subject: [PATCH 6.12 349/422] crypto: qce - unregister previously registered algos in error path Date: Thu, 13 Feb 2025 15:28:18 +0100 Message-ID: <20250213142450.020110863@linuxfoundation.org> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250213142436.408121546@linuxfoundation.org> References: <20250213142436.408121546@linuxfoundation.org> User-Agent: quilt/0.68 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.12-stable review patch. If anyone has any objections, please let me know. ------------------ From: Bartosz Golaszewski commit e80cf84b608725303113d6fe98bb727bf7b7a40d upstream. If we encounter an error when registering alorithms with the crypto framework, we just bail out and don't unregister the ones we successfully registered in prior iterations of the loop. Add code that goes back over the algos and unregisters them before returning an error from qce_register_algs(). Cc: stable@vger.kernel.org Fixes: ec8f5d8f6f76 ("crypto: qce - Qualcomm crypto engine driver") Signed-off-by: Bartosz Golaszewski Reviewed-by: Neil Armstrong Signed-off-by: Herbert Xu Signed-off-by: Greg Kroah-Hartman --- drivers/crypto/qce/core.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) --- a/drivers/crypto/qce/core.c +++ b/drivers/crypto/qce/core.c @@ -51,16 +51,19 @@ static void qce_unregister_algs(struct q static int qce_register_algs(struct qce_device *qce) { const struct qce_algo_ops *ops; - int i, ret = -ENODEV; + int i, j, ret = -ENODEV; for (i = 0; i < ARRAY_SIZE(qce_ops); i++) { ops = qce_ops[i]; ret = ops->register_algs(qce); - if (ret) - break; + if (ret) { + for (j = i - 1; j >= 0; j--) + ops->unregister_algs(qce); + return ret; + } } - return ret; + return 0; } static int qce_handle_request(struct crypto_async_request *async_req)