From patchwork Tue Jan 28 14:05:27 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg Kroah-Hartman X-Patchwork-Id: 232559 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4E219C2D0DB for ; Tue, 28 Jan 2020 14:36:15 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 16AF521739 for ; Tue, 28 Jan 2020 14:36:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1580222175; bh=dh2i587zdnnXchzuqp6Q+w7nspJszCKKud0jJOZMldg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=qsxScaXYumf+XA2lGVppMTDpFknS6tFB14jiKvA33A72jn3xMONyPT7RuqjJSfvMX YbLUhwCAN4aohQlaPnOdBrvEk1nnNfad1KyRyWz9cxUFsrN5pSe314Nh5EdYqdFlTw VV0/QNbWSN50WJT3y0IVDpgY+DBlStFopiCUoeWY= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727782AbgA1OWH (ORCPT ); Tue, 28 Jan 2020 09:22:07 -0500 Received: from mail.kernel.org ([198.145.29.99]:47756 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730349AbgA1OWG (ORCPT ); Tue, 28 Jan 2020 09:22:06 -0500 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 6609624696; Tue, 28 Jan 2020 14:22:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1580221325; bh=dh2i587zdnnXchzuqp6Q+w7nspJszCKKud0jJOZMldg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Hvph4LnvLckhCUKazP1bd+xucwlldZhgeMkIKA7i+7GNdHuFqPi6OZ6lRkjLjtSOi /Uy4fNi84b/TPRl/KFXyOA0zFHg8vyc4PEvxdOze5jCwOHALcCy0Vtj1oNRgApdHM4 GtzX3rFh3KUe3gbu0lP5sYPA4He1JCawQJwOLyLw= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Iuliana Prodan , Horia Geanta , Herbert Xu , Sasha Levin Subject: [PATCH 4.9 178/271] crypto: caam - free resources in case caam_rng registration failed Date: Tue, 28 Jan 2020 15:05:27 +0100 Message-Id: <20200128135905.793901133@linuxfoundation.org> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200128135852.449088278@linuxfoundation.org> References: <20200128135852.449088278@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Iuliana Prodan [ Upstream commit c59a1d41672a89b5cac49db1a472ff889e35a2d2 ] 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 Signed-off-by: Herbert Xu Signed-off-by: Sasha Levin --- 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 9b92af2c72412..a77319bf221d8 100644 --- a/drivers/crypto/caam/caamrng.c +++ b/drivers/crypto/caam/caamrng.c @@ -361,7 +361,10 @@ static int __init caam_rng_init(void) 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);