Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp6146595iog; Thu, 23 Jun 2022 12:18:21 -0700 (PDT) X-Google-Smtp-Source: AGRyM1tS/gMjpisD/Cgg1FWyoP8SoSQjjaYJZpzZxRKOXbVldMaznaUkwrdpOAjqCJ7FIIxmuZVv X-Received: by 2002:a17:907:968f:b0:722:f8ef:ab42 with SMTP id hd15-20020a170907968f00b00722f8efab42mr7871074ejc.258.1656011901618; Thu, 23 Jun 2022 12:18:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1656011901; cv=none; d=google.com; s=arc-20160816; b=Iksuhh1P5+3Ajeu4HMnVsvGgqDLTL/9PsEz5hzzAD++eRq1KyjLFeDJe+Ksrqhc1KD Ln9BSzulDiymAyzdc5OPSuDDLD1iWLJydckmwcLwRe3hFpGYUQt+osD4QtqVhUfcQk/M mHA3vmtpVktntewYY7bPaBun4Rqo9J3uMp/iJ/rcNaPCggkUaVGubLYUJVZtj+Mptow3 avFIyyrUgZ9EDib1yjXfPvTh0aeA05xXa7PSCtX8ncLWuwSSDXy5Y19eiQQI3zbREig5 qQd/I9Om399GBOUSbXb2haoqf/Ii6IR1PBfsSL2FRHn2RvPNLXf2+2hFYpw7I2IH03bn Oq2A== 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=CO3NoMS+s1OUnESDJQEOHWfkVbP7a/Gpe29wXsqu8Eg=; b=dGg21rBF0uyVdCw2fL84tL7Hyga+xpMi8iGfaoqKbhsNrdsC4ShupjLu+8qda7xQNb s/fTudCtVcCSPFQi1dAAUde7EqvhbsgUeT4KBSJIIE76+18FWZHe+xm1dJYb1KGtsQXT EG9JOM+dBPL8bMpj29Cysm3hrgbEid13kal0iWQn1k2z89k+fagFpE8UKZk+0ydsXC4q 140aP3C8by91EwVPxBn3rtyL4WHONJ2AiF4lZDL9IsZvBO+6I3svKo6NzQQ+bIc7oi8w hfQSNIOctAE+kjcXpSLNll1SHDeB7j/eKYyWoSYK3FGCFGacOmjwzDD73VhNRedbHa2g j5VA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=wH5F2ITv; 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 e3-20020a17090658c300b006f3916bcfc8si27770389ejs.142.2022.06.23.12.17.55; Thu, 23 Jun 2022 12:18:21 -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=wH5F2ITv; 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 S229459AbiFWRQd (ORCPT + 99 others); Thu, 23 Jun 2022 13:16:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39182 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233296AbiFWRMo (ORCPT ); Thu, 23 Jun 2022 13:12:44 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 11F5F4BFEC; Thu, 23 Jun 2022 09:58:35 -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 B3FEEB8248C; Thu, 23 Jun 2022 16:58:33 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0DA5AC3411B; Thu, 23 Jun 2022 16:58:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1656003512; bh=cHya7HynFnkggTlEZbyE6ZWrxenAhIKzXBwyjYNPLkA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=wH5F2ITvvf8boKtJB8sE/ZrEtWk00iktBXY8xas5/G47dtVAaWgQPOdDOw4hrQ41d /s+AJnTh5KzRIOQsn+Xu1gY2dugCNPBwoNExm/n6RAJ6bD1k/myKcQVy/pVsPYs/S9 cNBOHFWLNBNdeoY+ARDOjVcjnBlIyD9meZqJi9Cc= 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.9 222/264] random: avoid checking crng_ready() twice in random_init() Date: Thu, 23 Jun 2022 18:43:35 +0200 Message-Id: <20220623164350.359718044@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220623164344.053938039@linuxfoundation.org> References: <20220623164344.053938039@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 @@ -835,7 +835,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; }