Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp2904388ybi; Thu, 18 Jul 2019 16:59:22 -0700 (PDT) X-Google-Smtp-Source: APXvYqyBH8JFy8eMLRfgDnkTDDTjVFYoM8O3CHoxnBymY7qKAT+AQPNvxTHcj3PlChIcJmvz0xKj X-Received: by 2002:a63:4f51:: with SMTP id p17mr27089204pgl.333.1563494362753; Thu, 18 Jul 2019 16:59:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1563494362; cv=none; d=google.com; s=arc-20160816; b=hPNjdNjicrZs1TpqmMAKXKA//yea0P2vjQ61tuB0fTYZskJXLdX2zinbSXnq1JyOxz Gc6Gsmy8cvWu6qybyrTJg6jKF+W09Lu0lpbKBy206UZ1UFZoieMLXL7TqPPUV6ExymZy 8lYTsv6qEkXHgoxkMqYn2HZHU+B7AAHc3hMXm6TV0bDtbjE/SJoV0U+zJ2WZv70DUX7v ZsrI63BmRj+gk0eUhkIn38bx0wT9X20sSyS69LQRcm9CxYhKZ/DeYYTcwRPou1YE/qNp LqceQgxoYypcq/m3yZbsVFz8CsjyT+nBZXFYXeL7CDnWD/IypScOWlq+B2+URNprXOtT Kqhw== 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=D/tD2Emo3sjo0kbY2Szxq5TqkzKGcVLrPBX6dkpUwdI=; b=ywnstdlHQaqpA5khijF72eJttK2AWnT8alYwWZEgTplJfoPa20AFJaS3kXVLHpXB/W VjxISdddEvKPBP1261qBpEfIISm0L0Oa9yxm/ACKIgqBPOFUuw4ZieAqjRiwHBktLUQG 34uxsSuiThtClkPy7dCi9+vz0Uhd+gNoa0vV3Wd550JrDbme7iAhGnlUBe7O0mOvYBAR pxy6aGCyHadfzNeVVAYujj97yLPuezh/7teiCz6QjDp/WBo5bG3pPtiHvTLfwKyhRNPA hAr8+g7nn1y4FQeB0Wlj0g4V4L1F4hYoINqa+zjMuiJKBj1+DKu+9ZSR4y9ZKS+UyyXs wbyA== 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; 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 18si85884pgy.84.2019.07.18.16.59.06; Thu, 18 Jul 2019 16:59:22 -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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=nxp.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726483AbfGRX6U (ORCPT + 99 others); Thu, 18 Jul 2019 19:58:20 -0400 Received: from inva021.nxp.com ([92.121.34.21]:53200 "EHLO inva021.nxp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726317AbfGRX6S (ORCPT ); Thu, 18 Jul 2019 19:58:18 -0400 Received: from inva021.nxp.com (localhost [127.0.0.1]) by inva021.eu-rdc02.nxp.com (Postfix) with ESMTP id 7F8762003A4; Fri, 19 Jul 2019 01:58:16 +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 70A5D200003; Fri, 19 Jul 2019 01:58:16 +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 1E4B6205D1; Fri, 19 Jul 2019 01:58:16 +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 v2 11/14] crypto: caam - free resources in case caam_rng registration failed Date: Fri, 19 Jul 2019 02:57:53 +0300 Message-Id: <1563494276-3993-12-git-send-email-iuliana.prodan@nxp.com> X-Mailer: git-send-email 2.1.0 In-Reply-To: <1563494276-3993-1-git-send-email-iuliana.prodan@nxp.com> References: <1563494276-3993-1-git-send-email-iuliana.prodan@nxp.com> X-Virus-Scanned: ClamAV using ClamSMTP Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Check the return value of the hardware registration for caam_rng and free resources in case of failure. Fixes: 6e4e603a9 ("crypto: caam - Dynamic memory allocation for caam_rng_ctx object") Signed-off-by: Iuliana Prodan --- 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