Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp2509955imm; Thu, 7 Jun 2018 11:52:29 -0700 (PDT) X-Google-Smtp-Source: ADUXVKKTmXDr238z1+RJ92TTwkwOFkJ46V9rY8gZIRi+lp9BGcbQt/ozwWo5qtIja82ZBiv/8i8z X-Received: by 2002:a17:902:981:: with SMTP id 1-v6mr3202146pln.11.1528397549684; Thu, 07 Jun 2018 11:52:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528397549; cv=none; d=google.com; s=arc-20160816; b=IIXpVaBnH7X+b0F0TU7RHe/cTA2vNf3p6b0xFjF12VX/QLOAWlvuTSSBDQnzWimpje sC9koYVFXaTwGITz2hDmQkn7rnenGuzUW563cSQJakBJXZtQ4j95OGmvaOrQLcZqcrrg nt0kR8gWdiFmBUx77mfBB97VvX9KAGbK6l/vEwdRsASAJRB/PT6xC25BYu4uz0P0t6Zd 0tf7DcTtXRIfQXh4K6/iWJ4lZh0WX0ij800Km0uBAwaLMq9Uo2zCfdOBB00bT1bwdk31 47ki5xModZ5WmIcaJxDvDIjx7hhiTEfCTeYqAGsB2rPo3UDW0GqQBCf2RLtgcW3UJV6D +28A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:subject:message-id:date:cc:to :from:mime-version:content-transfer-encoding:content-disposition :arc-authentication-results; bh=kDWpCRxn7icfb5hgPeztoVlWLq4jBfnOXxYqFR+nWJA=; b=hiGfckPEbozrsnuWZHh1sczTRcOOAoLCMqhyAmRzvcOjyLWGarK785m8HIh9qGiao6 TrPcP4wt5MyVT5j83cDFcyipWYlaKFhBAuSjDeup9B+HcvCwZ4IzjL12jupzpTGy5hF3 +HCkDmMemAGE9kjRwMoBtTVI7+DL+hjA7o1OZu3y3hM7DKMKeVdWERF7Zm6e6w6MpYgH BtyjE7/Y1jjmqGQ4HPtSELQEgl1ctCINEO82bW/XF6Cc12ysBpZ9MWPwLNTmyjK9jmul BEMz60bABqRwsSqUjod6fztCk83qsWStIdyplajI4oL77LE/EL7pVpw4BlbIzqosoPQk 3AcA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p2-v6si32644266pls.551.2018.06.07.11.52.15; Thu, 07 Jun 2018 11:52:29 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S935790AbeFGPW6 (ORCPT + 99 others); Thu, 7 Jun 2018 11:22:58 -0400 Received: from shadbolt.e.decadent.org.uk ([88.96.1.126]:41219 "EHLO shadbolt.e.decadent.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S935544AbeFGO6u (ORCPT ); Thu, 7 Jun 2018 10:58:50 -0400 Received: from [148.252.241.226] (helo=deadeye) by shadbolt.decadent.org.uk with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1fQvbe-0005hL-EK; Thu, 07 Jun 2018 15:09:38 +0100 Received: from ben by deadeye with local (Exim 4.91) (envelope-from ) id 1fQvb6-000324-Ot; Thu, 07 Jun 2018 15:09:04 +0100 Content-Type: text/plain; charset="UTF-8" Content-Disposition: inline Content-Transfer-Encoding: 8bit MIME-Version: 1.0 From: Ben Hutchings To: linux-kernel@vger.kernel.org, stable@vger.kernel.org CC: akpm@linux-foundation.org, "Herbert Xu" , "=?UTF-8?q?Horia=20Geant=C4=83?=" , "Auer Lukas" , "Bryan O'Donoghue" Date: Thu, 07 Jun 2018 15:05:21 +0100 Message-ID: X-Mailer: LinuxStableQueue (scripts by bwh) Subject: [PATCH 3.16 218/410] crypto: caam - fix endless loop when DECO acquire fails In-Reply-To: X-SA-Exim-Connect-IP: 148.252.241.226 X-SA-Exim-Mail-From: ben@decadent.org.uk X-SA-Exim-Scanned: No (on shadbolt.decadent.org.uk); SAEximRunCond expanded to false Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 3.16.57-rc1 review patch. If anyone has any objections, please let me know. ------------------ From: Horia Geantă commit 225ece3e7dad4cfc44cca38ce7a3a80f255ea8f1 upstream. In case DECO0 cannot be acquired - i.e. run_descriptor_deco0() fails with -ENODEV, caam_probe() enters an endless loop: run_descriptor_deco0 ret -ENODEV -> instantiate_rng -ENODEV, overwritten by -EAGAIN ret -EAGAIN -> caam_probe -EAGAIN results in endless loop It turns out the error path in instantiate_rng() is incorrect, the checks are done in the wrong order. Fixes: 1005bccd7a4a6 ("crypto: caam - enable instantiation of all RNG4 state handles") Reported-by: Bryan O'Donoghue Suggested-by: Auer Lukas Signed-off-by: Horia Geantă Signed-off-by: Herbert Xu [bwh: Backported to 3.16: adjust context] Signed-off-by: Ben Hutchings --- drivers/crypto/caam/ctrl.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) --- a/drivers/crypto/caam/ctrl.c +++ b/drivers/crypto/caam/ctrl.c @@ -196,12 +196,16 @@ static int instantiate_rng(struct device * without any error (HW optimizations for later * CAAM eras), then try again. */ + if (ret) + break; + rdsta_val = rd_reg32(&topregs->ctrl.r4tst[0].rdsta) & RDSTA_IFMASK; - if (status || !(rdsta_val & (1 << sh_idx))) + if (status || !(rdsta_val & (1 << sh_idx))) { ret = -EAGAIN; - if (ret) break; + } + dev_info(ctrldev, "Instantiated RNG4 SH%d\n", sh_idx); /* Clear the contents before recreating the descriptor */