From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id AE37FCCA47F for ; Mon, 13 Jun 2022 08:09:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235910AbiFMIJZ (ORCPT ); Mon, 13 Jun 2022 04:09:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35038 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239511AbiFMIJC (ORCPT ); Mon, 13 Jun 2022 04:09:02 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B21BE12ACD for ; Mon, 13 Jun 2022 01:09:01 -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 dfw.source.kernel.org (Postfix) with ESMTPS id 4D179610A2 for ; Mon, 13 Jun 2022 08:09:01 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 60DA5C34114; Mon, 13 Jun 2022 08:09:00 +0000 (UTC) Authentication-Results: smtp.kernel.org; dkim=pass (1024-bit key) header.d=zx2c4.com header.i=@zx2c4.com header.b="drowkHz7" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=zx2c4.com; s=20210105; t=1655107738; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=i5gIktZxlqBTbiJQsNZFNduSdXsoKkfKv/JFiIbGY/4=; b=drowkHz7mAYEqsM1czDoHnF0RrhoLCp5NbPExIWyUCV7DSazYDf4kQtn+khwppWIiC2q5i EqXHwYIUEe67hPolWdslZCN5WbjINH6hLN5eLyaTA9viKBWjPA+Gz+yt4dQeySTVBZIs/S KLkmsmjPYogfVsmxIAnMOeZ4YoSZDUw= Received: by mail.zx2c4.com (ZX2C4 Mail Server) with ESMTPSA id c4e71e98 (TLSv1.3:AEAD-AES256-GCM-SHA384:256:NO); Mon, 13 Jun 2022 08:08:58 +0000 (UTC) From: "Jason A. Donenfeld" To: stable@vger.kernel.org, gregkh@linuxfoundation.org Subject: [PATCH stable 5.18 5.17 5.15 5.10 1/3] random: avoid checking crng_ready() twice in random_init() Date: Mon, 13 Jun 2022 10:07:47 +0200 Message-Id: <20220613080749.153222-2-Jason@zx2c4.com> In-Reply-To: <20220613080749.153222-1-Jason@zx2c4.com> References: <20220613080749.153222-1-Jason@zx2c4.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org commit 9b29b6b20376ab64e1b043df6301d8a92378e631 upstream. The current flow expands to: if (crng_ready()) ... else if (...) if (!crng_ready()) ... The second crng_ready() call is redundant, but can't so easily be optimized out by the compiler. This commit simplifies that to: if (crng_ready() ... else if (...) ... Fixes: 560181c27b58 ("random: move initialization functions out of hot pages") Cc: stable@vger.kernel.org Cc: Dominik Brodowski Signed-off-by: Jason A. Donenfeld --- drivers/char/random.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/char/random.c b/drivers/char/random.c index 420d78eee6c5..9972259809db 100644 --- a/drivers/char/random.c +++ b/drivers/char/random.c @@ -834,7 +834,7 @@ int __init random_init(const char *command_line) if (crng_ready()) crng_reseed(); else if (trust_cpu) - credit_init_bits(arch_bytes * 8); + _credit_init_bits(arch_bytes * 8); return 0; } -- 2.35.1