From patchwork Tue Dec 18 21:28:34 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 154195 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp4203795ljp; Tue, 18 Dec 2018 13:30:29 -0800 (PST) X-Google-Smtp-Source: AFSGD/VP3aZRcsC2FgT1zXIffHnNu042IV/h++4uHyG4m4sTaQAAi7waIg66JHG3vEjkUJ4CWiG7 X-Received: by 2002:a63:f74f:: with SMTP id f15mr17329261pgk.190.1545168629243; Tue, 18 Dec 2018 13:30:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1545168629; cv=none; d=google.com; s=arc-20160816; b=w/j0+hgoG/PKkiowzm9l6dhJ1cmLLxLQ9+U+FAvcB5Rch/wpZ2edm+pAxgcfkzQfWS 1/9v6jc4gG5WVYaHiMQqsWd/WW8o7m6MxqUPtrlxIRnLo1hyVKTXDzsoz6glCTXVMLkd UtcKjJF1DPmSnip3AA+Bhcxu3jKFs9bk8kc6M8oITX6qXe//j3TzXIouB7i5XKvNhqr6 dzL/9rW8ogNuAAKbA97+/KdR8XjQkvMBT2FSd1OL1QsZQRXfCKpY/3t4BX+n7UrOjEfv tQK08SmEtNhJLIx0B758Qpcb0Dt6ou7VoYsjwzyiePdU8UnnJ0+nd8FfAjimASqLi6X9 Sr0w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=8yYswTIddbl98Ij+qY0GbRy4Tl1Yh+JSAqMNtmY8jFQ=; b=s3mulznRCfs6hLGBEDLW2nor9WaWeLwkaOiwzoIx6edFUFpWRolpLe7SZ4SL+y07jh ONLUEJlfs5113D/CYAqnlmdmYHmOLEB1ZmwXN+x4S11HSMoBG1ksu4su3n9NlLcNbhpQ DEy3l/qS733NHzQz/orPxfam/p8b4PpV9MZ469ry2qkgz/Lrj8RNgJv8Bk7hvSlC5eZl fWD7xj9CReVFZ1cQMjARF/nuUR3/6kYbE96pq+2Ry7mZVcFX52jTo+gFM1tDQfowcDia s9NaYKVsDRXoZxArxZgTQQE1loAvzG42AembT3hKQlOe0ZyQ7iTmD0XXI9s6gK2fGf/e 6xdw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=g401sXmL; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l8si14429860pfc.98.2018.12.18.13.30.28; Tue, 18 Dec 2018 13:30:29 -0800 (PST) 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=@linaro.org header.s=google header.b=g401sXmL; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727687AbeLRV3k (ORCPT + 31 others); Tue, 18 Dec 2018 16:29:40 -0500 Received: from mail-wr1-f68.google.com ([209.85.221.68]:37374 "EHLO mail-wr1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727543AbeLRV3g (ORCPT ); Tue, 18 Dec 2018 16:29:36 -0500 Received: by mail-wr1-f68.google.com with SMTP id s12so16988898wrt.4 for ; Tue, 18 Dec 2018 13:29:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=8yYswTIddbl98Ij+qY0GbRy4Tl1Yh+JSAqMNtmY8jFQ=; b=g401sXmLhb+xsift8JwQPHt9yvnZ6iheN96seKdQflFPqI/ZKBiptVEpPyJcez7Fb6 geE1Jm15A8hVVVZRX9/S4wnZVXyvqat0L4Ov1e+mYLxlFLaN70Oo0Wk7I87LpdJb77tV hGW34U6YGwTZVyXgrEuWCllQJUqbC98tfhuzs= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=8yYswTIddbl98Ij+qY0GbRy4Tl1Yh+JSAqMNtmY8jFQ=; b=jKSXcqNWy3X0vZHrHxf6fSAIHmqFp/SJwNoyB6UV/Q8zViWSBHRUrlOItVKgjem4Ul x+mli3UVysrbOczwjb5TkISOavOPQGYDJijJEmhVlQCuYlRNdwHkaPxWXCRArcO6vRzj LJffwhbwtCbs8g7OBVexf6Zet+JxT1XzCOHfgaEco68dSd0KsJKm6/WVS1ny6A3iG6WQ kIGSCf1mKo0X23t1ymFS8Cp0WRcmbu8TTwSvIcWjMIsqnL7XqcuCX73CnTx93i4e+Ifs aIBzuSjzapY7D64HtvMyLEDDx5zQCnpEAFVaR0MnmyX5f52j0Vr8epFWuZTt/NRZsfb7 tbYA== X-Gm-Message-State: AA+aEWareAPpb9GCJkMWupoXMqTJwTs1XK8kq3oO0ItmCiPQReWgEzWq QHjcWugkbhh0ME6WXhEVEpqN0BfWW5Y= X-Received: by 2002:a05:6000:1287:: with SMTP id f7mr16992587wrx.302.1545168574098; Tue, 18 Dec 2018 13:29:34 -0800 (PST) Received: from localhost.localdomain (105.50.92.92.rev.sfr.net. [92.92.50.105]) by smtp.gmail.com with ESMTPSA id o4sm4153485wrq.66.2018.12.18.13.29.33 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 18 Dec 2018 13:29:33 -0800 (PST) From: Daniel Lezcano To: tglx@linutronix.de Cc: linux-kernel@vger.kernel.org, Yangtao Li Subject: [PATCH 16/25] clocksource/drivers/integrator-ap: Add missing of_node_put() Date: Tue, 18 Dec 2018 22:28:34 +0100 Message-Id: <20181218212844.30445-16-daniel.lezcano@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181218212844.30445-1-daniel.lezcano@linaro.org> References: <20181218212844.30445-1-daniel.lezcano@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Yangtao Li The function of_find_node_by_path() acquires a reference to the node returned by it and that reference needs to be dropped by its caller. integrator_ap_timer_init_of() doesn't do that. The pri_node and the sec_node are used as an identifier to compare against the current node, so we can directly drop the refcount after getting the node from the path as it is not used as pointer. By dropping the refcount right after getting it, a single variable is needed instead of two. Fix this by use a single variable and drop the refcount right after of_find_node_by_path(). Signed-off-by: Yangtao Li Signed-off-by: Daniel Lezcano --- drivers/clocksource/timer-integrator-ap.c | 25 +++++++++++++++-------- 1 file changed, 16 insertions(+), 9 deletions(-) -- 2.17.1 diff --git a/drivers/clocksource/timer-integrator-ap.c b/drivers/clocksource/timer-integrator-ap.c index 76e526f58620..19fb7de4b928 100644 --- a/drivers/clocksource/timer-integrator-ap.c +++ b/drivers/clocksource/timer-integrator-ap.c @@ -181,8 +181,7 @@ static int __init integrator_ap_timer_init_of(struct device_node *node) int irq; struct clk *clk; unsigned long rate; - struct device_node *pri_node; - struct device_node *sec_node; + struct device_node *alias_node; base = of_io_request_and_map(node, 0, "integrator-timer"); if (IS_ERR(base)) @@ -204,7 +203,18 @@ static int __init integrator_ap_timer_init_of(struct device_node *node) return err; } - pri_node = of_find_node_by_path(path); + alias_node = of_find_node_by_path(path); + + /* + * The pointer is used as an identifier not as a pointer, we + * can drop the refcount on the of__node immediately after + * getting it. + */ + of_node_put(alias_node); + + if (node == alias_node) + /* The primary timer lacks IRQ, use as clocksource */ + return integrator_clocksource_init(rate, base); err = of_property_read_string(of_aliases, "arm,timer-secondary", &path); @@ -213,14 +223,11 @@ static int __init integrator_ap_timer_init_of(struct device_node *node) return err; } + alias_node = of_find_node_by_path(path); - sec_node = of_find_node_by_path(path); - - if (node == pri_node) - /* The primary timer lacks IRQ, use as clocksource */ - return integrator_clocksource_init(rate, base); + of_node_put(alias_node); - if (node == sec_node) { + if (node == alias_node) { /* The secondary timer will drive the clock event */ irq = irq_of_parse_and_map(node, 0); return integrator_clockevent_init(rate, base, irq);