From patchwork Sat Oct 22 07:26:28 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 7535 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4242:0:0:0:0:0 with SMTP id s2csp1105860wrr; Sat, 22 Oct 2022 01:36:22 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7kefCmTKlcDc0YzwhdiHGicShXzgCKcZ8tV+DJhlfUUy2Nmz84+pnNhtR1Be5bC9XQvLbN X-Received: by 2002:a17:90b:4c52:b0:20d:7917:4cb3 with SMTP id np18-20020a17090b4c5200b0020d79174cb3mr62749058pjb.6.1666427771681; Sat, 22 Oct 2022 01:36:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666427771; cv=none; d=google.com; s=arc-20160816; b=R2AqgtP3CDoTZlgsrwoQ8RPXz4vLWWoYtWfo+ju+EaG9dEH2nRgoCISx33jA2wEEYW SiaidFYm7V+dgvTpSHSgblEwM1ZSpDc+YjRH/RCBdWvx4XiLQlZzGDQzBrCrsRTizxSD wswVRTj8ecHTSQTY2e9v/wNLY2jYcCiJA0ThBbBbkHUsFOGU+t9+hZjD50npBm1C6GYh nGOU2JyipcmJBhRy1OBh/5U6ADI99/acQXd1UWTi4z4ir3pfJUzAFLDrzurtx+3T/JSf OuwKAuH3GS4ZGKkCL8H7M/O7ZTxMEjUy2pIANsUb1RKmTuZ3VbN6CET8RU8GqwSerHiK 90Sw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=qEKNeIL4HkIK2GQ8U2jYZWfK3ac60MEC36bmrovh++I=; b=hMFEaxkqfBzpJ73XQZSNcw1BzVjYnL6xNc1Tjk7nWi6x/shxRay51eTtqWC+zfEaIG nNqHcvAJ/DPmBj2XolWJSRcPaYioqmruFtPCvIk9QOato3nGZoLk6de/uy04cGb2CU4w 3iqBHcDj2G2em3SJyQbEbVQYScBA1JSwQxO2UTYD56K0LzJzsHSZ4R3vpdYHRDzXj4RM wFSNLEfqUBKqlgjtbm+yYU7LDOKv2mwmT1ZKQQzi4l4sjhU6euvd1iItiSMZdPcsiGKd MjJKtSR1aNwGkOIGGFSBYlyoRYMzWY6DJVrsecxfdLvn1ZfJp8Ow68c1qS7wqk0pO8ET alpg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="vZfE9/Rd"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id eb9-20020a056a004c8900b0054342bb20e2si25092657pfb.66.2022.10.22.01.35.55; Sat, 22 Oct 2022 01:36:11 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="vZfE9/Rd"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233614AbiJVIWl (ORCPT + 99 others); Sat, 22 Oct 2022 04:22:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50600 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233688AbiJVIUo (ORCPT ); Sat, 22 Oct 2022 04:20:44 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D18752B5BAD; Sat, 22 Oct 2022 00:58:37 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 408ACB82E31; Sat, 22 Oct 2022 07:57:45 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 823AAC433C1; Sat, 22 Oct 2022 07:57:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666425463; bh=iLfJweqofE4ePh5lC+qqoU4eiN4c6k2V77N1oN0Csjg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=vZfE9/RdjGtcY19TDCgqBa0zDVNIQkKIc+KUgZOrwQvP4CdWLrrg4tPnsgv1RLXn5 F55buU55Tgi53N+Uv0bogebvrQhCAPgXf+XOm/Yb4O7YGDC6lZlQmKG3PIOUN6+DAj mtqg0kw9WXv/Y8Y8qsROOmhaxQNfVi9MX94j/Ius= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, James Cowgill , Herbert Xu , Sasha Levin Subject: [PATCH 5.19 509/717] hwrng: arm-smccc-trng - fix NO_ENTROPY handling Date: Sat, 22 Oct 2022 09:26:28 +0200 Message-Id: <20221022072520.767107550@linuxfoundation.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221022072415.034382448@linuxfoundation.org> References: <20221022072415.034382448@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 X-Spam-Status: No, score=-7.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747376166874463477?= X-GMAIL-MSGID: =?utf-8?q?1747376166874463477?= From: James Cowgill [ Upstream commit 042b4b169c6fb9d4df268d66282d7302dd73d37b ] The SMCCC_RET_TRNG_NO_ENTROPY switch arm is never used because the NO_ENTROPY return value is negative and negative values are handled above the switch by immediately returning. Fix by handling errors using a default arm in the switch. Fixes: 0888d04b47a1 ("hwrng: Add Arm SMCCC TRNG based driver") Signed-off-by: James Cowgill Signed-off-by: Herbert Xu Signed-off-by: Sasha Levin --- drivers/char/hw_random/arm_smccc_trng.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/char/hw_random/arm_smccc_trng.c b/drivers/char/hw_random/arm_smccc_trng.c index b24ac39a903b..e34c3ea692b6 100644 --- a/drivers/char/hw_random/arm_smccc_trng.c +++ b/drivers/char/hw_random/arm_smccc_trng.c @@ -71,8 +71,6 @@ static int smccc_trng_read(struct hwrng *rng, void *data, size_t max, bool wait) MAX_BITS_PER_CALL); arm_smccc_1_1_invoke(ARM_SMCCC_TRNG_RND, bits, &res); - if ((int)res.a0 < 0) - return (int)res.a0; switch ((int)res.a0) { case SMCCC_RET_SUCCESS: @@ -88,6 +86,8 @@ static int smccc_trng_read(struct hwrng *rng, void *data, size_t max, bool wait) return copied; cond_resched(); break; + default: + return -EIO; } }