From patchwork Thu Sep 18 02:48:25 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rusty Russell X-Patchwork-Id: 4928671 Return-Path: X-Original-To: patchwork-kvm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 64F15BEEA5 for ; Thu, 18 Sep 2014 02:53:33 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id A1B1720179 for ; Thu, 18 Sep 2014 02:53:32 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id CADE320158 for ; Thu, 18 Sep 2014 02:53:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932164AbaIRCxQ (ORCPT ); Wed, 17 Sep 2014 22:53:16 -0400 Received: from ozlabs.org ([103.22.144.67]:49256 "EHLO ozlabs.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757052AbaIRCwC (ORCPT ); Wed, 17 Sep 2014 22:52:02 -0400 Received: by ozlabs.org (Postfix, from userid 1011) id 7953F1401EB; Thu, 18 Sep 2014 12:52:00 +1000 (EST) From: Rusty Russell To: Amos Kong , virtualization@lists.linux-foundation.org, kvm@vger.kernel.org, herbert@gondor.apana.org.au, m@bues.ch, mb@bu3sch.de, mpm@selenic.com, amit.shah@redhat.com, linux-kernel@vger.kernel.org Cc: Rusty Russell Subject: [PATCH 4/5] hw_random: don't double-check old_rng. Date: Thu, 18 Sep 2014 12:18:25 +0930 Message-Id: <1411008506-28349-4-git-send-email-rusty@rustcorp.com.au> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1411008506-28349-1-git-send-email-rusty@rustcorp.com.au> References: <87wq91odhf.fsf@rustcorp.com.au> <1411008506-28349-1-git-send-email-rusty@rustcorp.com.au> Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Spam-Status: No, score=-7.6 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Interesting anti-pattern. Signed-off-by: Rusty Russell --- drivers/char/hw_random/core.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/drivers/char/hw_random/core.c b/drivers/char/hw_random/core.c index b4a21e9521cf..6a34feca6b43 100644 --- a/drivers/char/hw_random/core.c +++ b/drivers/char/hw_random/core.c @@ -472,14 +472,13 @@ int hwrng_register(struct hwrng *rng) } old_rng = current_rng; + err = 0; if (!old_rng) { err = hwrng_init(rng); if (err) goto out_unlock; set_current_rng(rng); - } - err = 0; - if (!old_rng) { + err = register_miscdev(); if (err) { drop_current_rng();