Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp2931904iog; Mon, 20 Jun 2022 07:45:09 -0700 (PDT) X-Google-Smtp-Source: AGRyM1tFG+Jkr2zP2PYGaCcL87Ey5y/agGU3Gaa+xyycbndSS1pcF09OWp4Xoys5o/1bFwbdUGo/ X-Received: by 2002:a63:587:0:b0:405:559:6df1 with SMTP id 129-20020a630587000000b0040505596df1mr21437394pgf.355.1655736309344; Mon, 20 Jun 2022 07:45:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1655736309; cv=none; d=google.com; s=arc-20160816; b=Z1XJ/BXz3Lb8EzEYCHwwhfLbcg6OSiV5w7LGxW0vH4GVTC8X2rF6DdJKuy7sKW6n8B u8CdLV5/hOXHm6uA0Wiv5C/rCMWNO7tsqxDklNezj0HjFhf19DREoyFOT+l1UgvwXxmX cfxyRAe5c5Q4FptWfL2ENMikbur3Fx4OuuK2xMrWKsChRT044MMzrzLZGw20VeIgtImt TtOWteZGwGWa30SiPJ/MoDOK0MO5GoM9i18iQ2FTtvTPXzVV+brhGoyOSNks9+siAyOS UyxovtxNQXhURuYRk8la+unEoKsK9KDftIZozKns5XOZ9bKK9ijPQq3WtJbqYOvxtqDg X/HA== 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=aqHptToh5U1Vlet/aw8j6t8CUeelCDb+srXKcN+WAlumf+GPAhKKusHvV769fNVYJr PcDLQt6cczy8HqjaE9QaKT+tXFQcQVP0gWMIQBUfHENtG227Iy5R8QJgIE+BcRJYVMrc Lt10Jm96EVPCDkkeGLlRZ8r1zujgVxxdVN13A0gyQjikXmiTmWzAwq5VkmpSOd8Cwt09 CymU8KK0nfuTnPeewMTpshafm3PeiLHUFfXR99ruBvFE0EpJrz7Ph2ivmrtJPc5+tlkg gyWqDjUAtu/9lwPUl2rRV6oMKxbvZAZl5I95U+V0km5FahlxJsvG0xGYmSu87Ti7oo8E +IFw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=YPRLamQg; 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 c5-20020aa781c5000000b0051bfad76f17si14555734pfn.100.2022.06.20.07.44.57; Mon, 20 Jun 2022 07:45:09 -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=YPRLamQg; 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 S1349099AbiFTOKe (ORCPT + 99 others); Mon, 20 Jun 2022 10:10:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36654 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1350874AbiFTNxy (ORCPT ); Mon, 20 Jun 2022 09:53:54 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EB34D20F78; Mon, 20 Jun 2022 06:20:25 -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 632B3B811A9; Mon, 20 Jun 2022 13:19:39 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id BEA0EC3411B; Mon, 20 Jun 2022 13:19:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1655731178; bh=ZIGf3OIICc/ZkZtAiW0hV2LGkW+W99wy51TwniPPSIY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=YPRLamQgDJ7BMByzYpGbP8xbdRambB6NScElYjgMuQX5S+tp3FfaTPK2eVbC+RzI1 udTws95uBXrBjLX1J1cqKf1B2Im9KDO0dhIvrdHTdBiLRS3+ISv/rcLK87gdTTZRe3 +Wj7scdyPI7bx0snlDEHm+aCZ0pcj+t0EVqpVXXw= 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 5.4 178/240] random: avoid checking crng_ready() twice in random_init() Date: Mon, 20 Jun 2022 14:51:19 +0200 Message-Id: <20220620124744.154108727@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220620124737.799371052@linuxfoundation.org> References: <20220620124737.799371052@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; }