Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp5961805ybi; Wed, 31 Jul 2019 06:09:23 -0700 (PDT) X-Google-Smtp-Source: APXvYqxOFfy5yCAuHTG4VoPa78KmjfEHOxAJG9QPrsQdQuT3FPgi76/v/YqX0ShP/u0JC+j0uM6Q X-Received: by 2002:a62:750c:: with SMTP id q12mr48777964pfc.59.1564578563198; Wed, 31 Jul 2019 06:09:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564578563; cv=none; d=google.com; s=arc-20160816; b=eOkZyqgtWMsWRAqmBP7986AIxOhGvopJeXPcqS5wodpkh2O9aQlwz916PeqqvJB/oP ogQU5MiG7Yr02W4IhoT+N7JSHcpTuQQRJam2U2mvdP83MnRTmuIQOU3b1zBAcwskePpV Z5Wu6IZXaxzzIgjd0dGACszDLcCR2iChd1eMJflit8U2E/SX2C/jX+U5AKyfJXKRdx+5 r3WAGoxDqS8dQ5HULgnomX7r/hySdr5blrXMzNH9Ih0/hHPhCjFvFHtCgqxUtrTBXxBN TnM0I4woo9sbbxKl/U8Uw7rzXnzfcmCJNnPkUM/Fq3Grcs8LK2T5ct+TF/xsOp04sou7 PaHA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=Y7H2/nOPwHSNiq21SlqvTHiIsGEImeK7U+TefotrbJg=; b=YeSOm9tA/oW3KdlOZruvO+7k3ASYVL4CTL1LG1z8HP3DBQATUL6YKEPKrxy5feR2sh 2A3kRu7S/M5lgSqpjvQWPHqVVn/ylfS7ZOnTN7BstGLqTKlfPi78HWds+LUHSLlT1KvN y3cVKxrk4fYlEPolDsXVul0vEPGBnj/O+xNNPXuAXQIVuGC+nh7Y5pxSxtJOJc34Mmmv YO1AAzGQzuXZtB+lr9D2wJi+riip2VnTUxpnRE2Ek5jRG5iWG/JWEwxvr3LT7qNlyRyP 1h7p8y4fA06xN4B/xrMut4sSUtrbBk0fQ8yy57vaR3mUbu5GiNJjwTChl/jgN2dd99AC HmhQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-crypto-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=nxp.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 73si31446743pfa.123.2019.07.31.06.09.09; Wed, 31 Jul 2019 06:09:23 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-crypto-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-crypto-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=nxp.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729324AbfGaNIo (ORCPT + 99 others); Wed, 31 Jul 2019 09:08:44 -0400 Received: from inva021.nxp.com ([92.121.34.21]:42812 "EHLO inva021.nxp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388157AbfGaNI0 (ORCPT ); Wed, 31 Jul 2019 09:08:26 -0400 Received: from inva021.nxp.com (localhost [127.0.0.1]) by inva021.eu-rdc02.nxp.com (Postfix) with ESMTP id 33B37200A1E; Wed, 31 Jul 2019 15:08:25 +0200 (CEST) Received: from inva024.eu-rdc02.nxp.com (inva024.eu-rdc02.nxp.com [134.27.226.22]) by inva021.eu-rdc02.nxp.com (Postfix) with ESMTP id 26FFD200042; Wed, 31 Jul 2019 15:08:25 +0200 (CEST) Received: from lorenz.ea.freescale.net (lorenz.ea.freescale.net [10.171.71.5]) by inva024.eu-rdc02.nxp.com (Postfix) with ESMTP id C8916205F3; Wed, 31 Jul 2019 15:08:24 +0200 (CEST) From: Iuliana Prodan To: Herbert Xu , Horia Geanta , Aymen Sghaier Cc: "David S. Miller" , linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org, linux-imx Subject: [PATCH v5 11/14] crypto: caam - free resources in case caam_rng registration failed Date: Wed, 31 Jul 2019 16:08:12 +0300 Message-Id: <1564578495-9883-12-git-send-email-iuliana.prodan@nxp.com> X-Mailer: git-send-email 2.1.0 In-Reply-To: <1564578495-9883-1-git-send-email-iuliana.prodan@nxp.com> References: <1564578495-9883-1-git-send-email-iuliana.prodan@nxp.com> X-Virus-Scanned: ClamAV using ClamSMTP Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org Check the return value of the hardware registration for caam_rng and free resources in case of failure. Fixes: e24f7c9e87d4 ("crypto: caam - hwrng support") Signed-off-by: Iuliana Prodan Reviewed-by: Horia Geanta --- drivers/crypto/caam/caamrng.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/crypto/caam/caamrng.c b/drivers/crypto/caam/caamrng.c index 561bcb5..54c32d5 100644 --- a/drivers/crypto/caam/caamrng.c +++ b/drivers/crypto/caam/caamrng.c @@ -333,7 +333,10 @@ int caam_rng_init(struct device *ctrldev) goto free_rng_ctx; dev_info(dev, "registering rng-caam\n"); - return hwrng_register(&caam_rng); + + err = hwrng_register(&caam_rng); + if (!err) + return err; free_rng_ctx: kfree(rng_ctx); -- 2.1.0