From patchwork Tue Dec 1 17:39:31 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Anholt X-Patchwork-Id: 7739171 X-Patchwork-Delegate: rjw@sisk.pl Return-Path: X-Original-To: patchwork-linux-pm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 1E0BD9F387 for ; Tue, 1 Dec 2015 17:39:37 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 37B9820425 for ; Tue, 1 Dec 2015 17:39:36 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 49DC620490 for ; Tue, 1 Dec 2015 17:39:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756395AbbLARje (ORCPT ); Tue, 1 Dec 2015 12:39:34 -0500 Received: from gabe.freedesktop.org ([131.252.210.177]:39474 "EHLO gabe.freedesktop.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756169AbbLARjd (ORCPT ); Tue, 1 Dec 2015 12:39:33 -0500 Received: from annarchy.freedesktop.org (annarchy.freedesktop.org [131.252.210.176]) by gabe.freedesktop.org (Postfix) with ESMTP id 09D3C6E064; Tue, 1 Dec 2015 09:39:33 -0800 (PST) Received: from eliezer.anholt.net (annarchy.freedesktop.org [127.0.0.1]) by annarchy.freedesktop.org (Postfix) with ESMTP id ED07118176; Tue, 1 Dec 2015 09:39:32 -0800 (PST) Received: by eliezer.anholt.net (Postfix, from userid 1000) id E0B0BF1BFD8; Tue, 1 Dec 2015 09:39:31 -0800 (PST) From: Eric Anholt To: linux-kernel@vger.kernel.org Cc: "Rafael J . Wysocki" , Kevin Hilman , Ulf Hansson , linux-pm@vger.kernel.org, Eric Anholt Subject: [PATCH] PM / Domains: Fix bad of_node_put() in failure paths of genpd_dev_pm_attach() Date: Tue, 1 Dec 2015 09:39:31 -0800 Message-Id: <1448991571-20301-1-git-send-email-eric@anholt.net> X-Mailer: git-send-email 2.6.2 Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_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 It looks like these meant to be unreffing the of_parse_phandle_with_args() node, since the error paths above it don't do of_node_put. That function returns a new ref in pd_args.np, though, not a new ref on dev->of_node. Also, it would have leaked the ref in the success case. Fixes "ERROR: Bad of_node_put()" on bcm2835 when hitting the -EPROBE_DEFER case. Signed-off-by: Eric Anholt Acked-by: Ulf Hansson --- drivers/base/power/domain.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c index e03b1ad..167418e 100644 --- a/drivers/base/power/domain.c +++ b/drivers/base/power/domain.c @@ -1775,10 +1775,10 @@ int genpd_dev_pm_attach(struct device *dev) } pd = of_genpd_get_from_provider(&pd_args); + of_node_put(pd_args.np); if (IS_ERR(pd)) { dev_dbg(dev, "%s() failed to find PM domain: %ld\n", __func__, PTR_ERR(pd)); - of_node_put(dev->of_node); return -EPROBE_DEFER; } @@ -1796,7 +1796,6 @@ int genpd_dev_pm_attach(struct device *dev) if (ret < 0) { dev_err(dev, "failed to add to PM domain %s: %d", pd->name, ret); - of_node_put(dev->of_node); goto out; }