Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp6144097iog; Thu, 23 Jun 2022 12:15:36 -0700 (PDT) X-Google-Smtp-Source: AGRyM1vj+O1lHPgpyvIlcelE52JA2GI+Jmi8ZXhW0pqhV0bzaH8NPpK8atGKIZNa8r5o4DAStHHc X-Received: by 2002:a63:9044:0:b0:40c:9a2e:5b88 with SMTP id a65-20020a639044000000b0040c9a2e5b88mr8949892pge.214.1656011736486; Thu, 23 Jun 2022 12:15:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1656011736; cv=none; d=google.com; s=arc-20160816; b=RjH4fhOzi//CE19QkMSO7tCQs5P4VrbkY5D9rgXf+7p2cgOqxrQejPygjEyWw9e2vG f7isugANZhZSBI8q0XSpWuzaW+aDSPHTcruHIoJrySW5HNpo3ffwklEkHWQQKH+HXRM7 /X8QC0Z6MoLlNERctUp4kqOVR7i1jv5+0X9QFptvef1PnKgr6cX9eRa5WdN1ZjuNm204 xrbU16WbqwmMfutwzDWcYc7lXq+0GH534+Gd2Eo/ik1eLNelROupHo9vgl9k9x/pGZJs OKLV/AIkEVDccCRX+yoxudiHO+N6KxbUvnTBrS2bGVfnRuj3bVgjlzCFCjdWjS0f2tlS O7Jw== 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=VVuyHjUfUttEz3fGV4DiaaPoPjvS3+k2OZh/Eggzgxo=; b=tJnfsKK7DUNVNO9oi1YRfupci5KINLHnNPr8Dg65iRZkNZbc83vOi1ymq7wq0/UdX4 RfL5/T6NZHGnVfKNdG0V9AEbSy4XEjGI1WxHIfrBR4LcYdACxIz1OfMDaHqEo9jhsyMN F2Iet308TKhi2bCRwUsDjbjWXPyVUMJDxKGTbaouH+3jfSh1jd4xzdqFrAtZ90+cFRP5 D1UrsVt1AwNwdC9U73F65USDVYSZhLRcch8XbN3y4HCFyDcbuYqpYWS5HktpQm1YeMEy TMyoXxY0w5gx1Q+ZDY7XcyuJiFi0apgP7XlLaIQOBreBbFT5tplkJuNZWaW4Atx/VpQf RYSA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=VPUmdnYX; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 25-20020a631159000000b003fbcd6ecc16si7653pgr.18.2022.06.23.12.15.24; Thu, 23 Jun 2022 12:15:36 -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=VPUmdnYX; 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 S236618AbiFWSOv (ORCPT + 99 others); Thu, 23 Jun 2022 14:14:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56642 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236937AbiFWSNN (ORCPT ); Thu, 23 Jun 2022 14:13:13 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DF6B89A852; Thu, 23 Jun 2022 10:21:14 -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 6A42CB824B8; Thu, 23 Jun 2022 17:21:13 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C2FD3C3411B; Thu, 23 Jun 2022 17:21:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1656004872; bh=ZIGf3OIICc/ZkZtAiW0hV2LGkW+W99wy51TwniPPSIY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=VPUmdnYXoDJwLTYOyxUKjMOHJOYLahYxh99r2zqYtqFFXxJ+wgbNAvM5H0yEyjeUR nH5Sh4WZ2UCYzqgeLG+myHTLpt0uR//d2+V2FlN2FzKwJ7Q7HwWtZDlOSsQEE60VpR 0p7CQQgXfKcIJUHrsIrpkxph+zxDOCv8WIxab+e0= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Dominik Brodowski , "Jason A. Donenfeld" Subject: [PATCH 4.19 178/234] random: avoid checking crng_ready() twice in random_init() Date: Thu, 23 Jun 2022 18:44:05 +0200 Message-Id: <20220623164348.088536062@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220623164343.042598055@linuxfoundation.org> References: <20220623164343.042598055@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.7 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,T_SCC_BODY_TEXT_LINE 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 From: "Jason A. Donenfeld" 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 Signed-off-by: Greg Kroah-Hartman --- drivers/char/random.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/drivers/char/random.c +++ b/drivers/char/random.c @@ -834,7 +834,7 @@ int __init random_init(const char *comma if (crng_ready()) crng_reseed(); else if (trust_cpu) - credit_init_bits(arch_bytes * 8); + _credit_init_bits(arch_bytes * 8); return 0; }