From patchwork Fri Sep 26 13:33:46 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lucas Stach X-Patchwork-Id: 4983431 Return-Path: X-Original-To: patchwork-linux-pm@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 499A3BEEA6 for ; Fri, 26 Sep 2014 13:33:53 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 52B9A2020F for ; Fri, 26 Sep 2014 13:33:51 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 7D583201E4 for ; Fri, 26 Sep 2014 13:33:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755238AbaIZNdt (ORCPT ); Fri, 26 Sep 2014 09:33:49 -0400 Received: from metis.ext.pengutronix.de ([92.198.50.35]:45800 "EHLO metis.ext.pengutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754825AbaIZNdt (ORCPT ); Fri, 26 Sep 2014 09:33:49 -0400 Received: from dude.hi.4.pengutronix.de ([10.1.0.7] helo=dude.pengutronix.de.) by metis.ext.pengutronix.de with esmtp (Exim 4.72) (envelope-from ) id 1XXVed-0002Lh-5v; Fri, 26 Sep 2014 15:33:47 +0200 From: Lucas Stach To: "Rafael J. Wysocki" , Viresh Kumar Cc: linux-pm@vger.kernel.org Subject: [PATCH] cpufreq: dt: fix potential double put of cpu OF node Date: Fri, 26 Sep 2014 15:33:46 +0200 Message-Id: <1411738426-18375-1-git-send-email-l.stach@pengutronix.de> X-Mailer: git-send-email 2.1.0 X-SA-Exim-Connect-IP: 10.1.0.7 X-SA-Exim-Mail-From: l.stach@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-pm@vger.kernel.org Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@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=unavailable 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 If cpufreq_generic_init() fails we jump into the resource cleanup path which contains a of_node_put() call. Another instance of this has already been called at that time resulting a double decrement of the refcount. Fix this by calling of_node_put() only after we are sure that nothing has gone wrong. Signed-off-by: Lucas Stach --- drivers/cpufreq/cpufreq-dt.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/cpufreq/cpufreq-dt.c b/drivers/cpufreq/cpufreq-dt.c index e00265066a75..6bbb8b913446 100644 --- a/drivers/cpufreq/cpufreq-dt.c +++ b/drivers/cpufreq/cpufreq-dt.c @@ -259,7 +259,6 @@ static int cpufreq_init(struct cpufreq_policy *policy) else priv->cdev = cdev; } - of_node_put(np); priv->cpu_dev = cpu_dev; priv->cpu_reg = cpu_reg; @@ -270,6 +269,8 @@ static int cpufreq_init(struct cpufreq_policy *policy) if (ret) goto out_cooling_unregister; + of_node_put(np); + return 0; out_cooling_unregister: