Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp2277964imm; Mon, 28 May 2018 05:15:48 -0700 (PDT) X-Google-Smtp-Source: AB8JxZqyZK0fwqf+/wVvI55VhqHNCD/DvHAkfbTtBED+fGIiaoSI1GAUPLr3G2ceeGjTVlJn4vNx X-Received: by 2002:a63:9302:: with SMTP id b2-v6mr10559237pge.263.1527509748463; Mon, 28 May 2018 05:15:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527509748; cv=none; d=google.com; s=arc-20160816; b=0fW3+RuhRaOHMwZ7vZIGaInPVYBctg0Mu7g8/OizEdFoWIDJSNu+U8xrq8u0/80rgM C0RPylXBVPH6oqBHjIQqSWW/uItVBn4qK7Hw12eZX2DRx462xV2hQjMlM23zOia9sVmF AhU4pftPYJnHgqrxlyxYb5Bk3bbBufo9HYCKuQVX6x4fu++6IgpWpIAdGQDQM3s9sv+H 3VSJvBbd/qHxi1IN3Y4X6SxsAnsaMjmXyBat8UMmRh4Ck9g7qIm7T2AYlsKje6iajpPt joLr7foLorN+6GvpM0kTlD/ED0WMu8oczfyn+pauFSGWs31tBJixT442Slt5paFkR3LW 6hyw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from:dkim-signature :arc-authentication-results; bh=K/Z/UurupkWA+nNIOzeYVhpgtzaemuc0FFHD8bi0yN8=; b=GVl5i6ei37kMhjDA+aozn8MOO1Iu4MmZKSk61oLGRBVn7JLakl6sYTCEUAZQ2aY4fn v/sPzWkr/hvljOexZb9k7V6wakJb0ffF6Vhy9+cVvUAjKoy4I6StDQfP4KFvk9QEkw6x KWDBBO5gwBdwzlVfAcOKmLMDFhuY2aloU+Bd1+ddsf64acybvYRENqC3H0wDOpMjKRrD YZTmED3pfv06aZShcVT94ISlp9c1PRt7PTEc/+EYliZ0VH+zEgkP3q/bxAxHd29xP/rc toCBvHyTxnJ1O0SPCXbIBNQ14uRyD+HJX7INgtk1H35f15cB8zukg/8/HYeiiZtryY+a 5vIg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=WhnjyhI2; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c13-v6si24413709pgt.649.2018.05.28.05.15.33; Mon, 28 May 2018 05:15:48 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=WhnjyhI2; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1423325AbeE1MPH (ORCPT + 99 others); Mon, 28 May 2018 08:15:07 -0400 Received: from mail.kernel.org ([198.145.29.99]:50852 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1422928AbeE1LDl (ORCPT ); Mon, 28 May 2018 07:03:41 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id A8A2A2088E; Mon, 28 May 2018 11:03:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1527505421; bh=bx+dH/fDvtAXJ7f875w21wo2YaEyhcyZm90rgn7AfzI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=WhnjyhI2iQaM+kVllGB94TPl9Z2v3m37FndK7B095nlmpQk3sBM5jJBRJPvkb6bfw peaBX3qGsrpbi4vtM/uZWPh6uSGagZj3tNzWYIcwmj5HGXfBRG23fzzEWrf+8GGuCB 30wuBQFbtVma4nNJ+tZluiWXvi5LYR9YrJ4zcEW8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Viresh Kumar , "Rafael J. Wysocki" , Sasha Levin Subject: [PATCH 4.14 460/496] cpufreq: Reorder cpufreq_online() error code path Date: Mon, 28 May 2018 12:04:05 +0200 Message-Id: <20180528100339.300856151@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180528100319.498712256@linuxfoundation.org> References: <20180528100319.498712256@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.14-stable review patch. If anyone has any objections, please let me know. ------------------ From: Viresh Kumar [ Upstream commit b24b6478e65f140610ab1ffaadc7bc6bf0be8aad ] Ideally the de-allocation of resources should happen in the exact opposite order in which they were allocated. It helps maintain the code in long term, even if nothing really breaks with incorrect ordering. That wasn't followed in cpufreq_online() and it has some inconsistencies. For example, the symlinks were created from within the locked region while they are removed only after putting the locks. Also ->exit() should have been called only after the symlinks are removed and the lock is dropped, as that was the case when ->init() was first called. Signed-off-by: Viresh Kumar [ rjw: Subject ] Signed-off-by: Rafael J. Wysocki Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- drivers/cpufreq/cpufreq.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) --- a/drivers/cpufreq/cpufreq.c +++ b/drivers/cpufreq/cpufreq.c @@ -1315,14 +1315,14 @@ static int cpufreq_online(unsigned int c return 0; out_exit_policy: + for_each_cpu(j, policy->real_cpus) + remove_cpu_dev_symlink(policy, get_cpu_device(j)); + up_write(&policy->rwsem); if (cpufreq_driver->exit) cpufreq_driver->exit(policy); - for_each_cpu(j, policy->real_cpus) - remove_cpu_dev_symlink(policy, get_cpu_device(j)); - out_free_policy: cpufreq_policy_free(policy); return ret;