Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp2239910imm; Mon, 28 May 2018 04:34:29 -0700 (PDT) X-Google-Smtp-Source: AB8JxZqhDHm8pgavaTCO1ORFdbDVR+4TfM4JuFbkXeih9FjCqzsKlMkeuQMS4nodOmoWiiB2Klny X-Received: by 2002:a63:711c:: with SMTP id m28-v6mr9377712pgc.66.1527507269653; Mon, 28 May 2018 04:34:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527507269; cv=none; d=google.com; s=arc-20160816; b=RtTYTDFPB4dIk1PEqE8/RkwJuBJmNjXxBU6y1oXeHheYXibh3jaPKBnAwbjmjVxza0 sqpe2+tYlmyQ2Uf/nlQ2ZBUiJbr7kMcIXTqHmfEnFDpENQpUA+3o++UmXT9svTRqRo/5 GG6E5JQIXTAGCGjtV4kUTY0MLMrjUNXgenuwkjipppFso0H6am1F1mpVbZQe1SNV5cKz aIeQ9q6gzwFTkmuhwfsJZqrPFDGN7y+sjuS2BR2TUReXpGXpIkQIPBVX+b7iOfXfdfyl 20qweslY8am9fhY2OicoGQq9ffedIV3/y20DvoUFVUnWNAcifkveO8zrFvHxTsN9Itte Bpxw== 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=nNSnDKrZtoaliTQEKWqU42odEnGmhoRm4YvHq4Y/9BU=; b=OofTYCcgKBPvb+wlBc9Tju73oMDU1fD/9SBCHXq0YsmP9L2EpHb6RArbl2yrvTkkZm rkTGCLcee/k5hycAzuAuutm44zb/jq0RMqIEukiYFmthj2TtsSWXSyG5+sf1DRrw2Cla xg9IC7BiTDtuL1mFdXaOkKPxgbM8MW7Ox4Ckv6TkpI6kOZ4uZxByFOhLT0I6PK5HZ4wu tSfwVeB8AegDUJusAnkTqtj/oVBbLb/jq7zbSNOscRkvUJuRPs/0rqt0X2SwNHacga8Z iE3Ky3t+XNa8bjWS817qjzA2JiYebG42mYy8fojpSt2I1+7CfxgpQT8Y+WXx6hlutez+ Yvfg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=JbD7OuFZ; 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 b14-v6si9914810pge.71.2018.05.28.04.34.15; Mon, 28 May 2018 04:34:29 -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=JbD7OuFZ; 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 S938318AbeE1LcV (ORCPT + 99 others); Mon, 28 May 2018 07:32:21 -0400 Received: from mail.kernel.org ([198.145.29.99]:33632 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1424396AbeE1LOU (ORCPT ); Mon, 28 May 2018 07:14:20 -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 D892A20845; Mon, 28 May 2018 11:14:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1527506060; bh=INt81dL75YIfXvFQxM/tBYl9w/gNFxzCVeKWPkbAgIY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=JbD7OuFZ/3L4q84qrfzIDrkpUM59a1LlMbnWfUHOgUqkYg9CeyzEVC0yRH6CDky2R Q59eL5F1QhH4h+PG3An6+l4PAFb+96kxkiDkmhhrsYq4AvfC6SaM5hrnapANSNMQC3 vilhRs4MN7S2v7LSlxi2N1/nqkakp3eKMyTiJjbw= 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.16 227/272] cpufreq: Reorder cpufreq_online() error code path Date: Mon, 28 May 2018 12:04:20 +0200 Message-Id: <20180528100259.512640011@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180528100240.256525891@linuxfoundation.org> References: <20180528100240.256525891@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.16-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 @@ -1327,14 +1327,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;