Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp2397392ybi; Thu, 18 Jul 2019 07:48:13 -0700 (PDT) X-Google-Smtp-Source: APXvYqzcQ/SxiCzXZ/xJXu1UTZhgP9syNfOgBBL4I9abSpjjxud2BQcZDc8CUSspIIDnvSU3hQOh X-Received: by 2002:a63:494d:: with SMTP id y13mr48945678pgk.109.1563461293344; Thu, 18 Jul 2019 07:48:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1563461293; cv=none; d=google.com; s=arc-20160816; b=NrZJQXuTmp6cyTfZNuT1hvuungyT3MudTQGSpwie3e2D1v2tWtqi/yXXBZwkjwTYBl xEf+5hYjYC6hGEPwGur5LR486AlcqmuZAQbwEpQxzB64MdYJ7lWDEh/UuOc+Zv72/Prg szfRDuGOrH1KHKZEC4CNCeoUxYw4P1LycQP+cPnKIDLWe3spYvkjXszbbBSqgDiFG+U4 9NEsmeIAklOHiW4KvAZE4Hdg7vWpTupQCSBwHsX8xlDQ/ql1t4fGq83XVwOgbjEnqcTA AS53t4tKOmhs5r2uf08pX+QxMGILYqWTmCoxO75qL3So8IbSfUTs+HxjqydBUvITaefw JNlQ== 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=EeEGbr5S4RRfgGdUi1S5KENQWQCCaH7BtctnsRFfzbUuGb/SxibX3WDrbnQgAVEW27 ePsRnPdoSGLMJZX8aaT3XI6JCKFb/XM7/TObNO/WfJj5ldPC4L2C+8W/nFmwITMd0Mxg gmnyJvA/P+C75l3BXm8qzHtoawFQmNEYqYiCcfz6FcEuzFxyzMddsSsUyrMDBkUL9ibG m5gt6AfeGR+egJLtrJ1dHaxGR3AMjssBoSseGCswq2XTdE+ZHPyQYqO6eor05FpP5vu5 XjSnodcL+Eo+abKID83R7jBhLab57CUBsmMcN7EqFRHML3BAb9gNvIITqzs3NhnmlaMG fxWQ== 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 u24si1876957plq.430.2019.07.18.07.47.59; Thu, 18 Jul 2019 07:48:13 -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 S2390897AbfGROqM (ORCPT + 99 others); Thu, 18 Jul 2019 10:46:12 -0400 Received: from inva020.nxp.com ([92.121.34.13]:49556 "EHLO inva020.nxp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390691AbfGROpm (ORCPT ); Thu, 18 Jul 2019 10:45:42 -0400 Received: from inva020.nxp.com (localhost [127.0.0.1]) by inva020.eu-rdc02.nxp.com (Postfix) with ESMTP id E8F5C1A0006; Thu, 18 Jul 2019 16:45:40 +0200 (CEST) Received: from inva024.eu-rdc02.nxp.com (inva024.eu-rdc02.nxp.com [134.27.226.22]) by inva020.eu-rdc02.nxp.com (Postfix) with ESMTP id DD3A01A035C; Thu, 18 Jul 2019 16:45:40 +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 87BC4205C7; Thu, 18 Jul 2019 16:45:40 +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 11/14] crypto: caam - free resources in case caam_rng registration failed Date: Thu, 18 Jul 2019 17:45:21 +0300 Message-Id: <1563461124-24641-12-git-send-email-iuliana.prodan@nxp.com> X-Mailer: git-send-email 2.1.0 In-Reply-To: <1563461124-24641-1-git-send-email-iuliana.prodan@nxp.com> References: <1563461124-24641-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: 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