Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753968AbcCYTzZ (ORCPT ); Fri, 25 Mar 2016 15:55:25 -0400 Received: from smtp-fw-6001.amazon.com ([52.95.48.154]:56393 "EHLO smtp-fw-6001.amazon.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751521AbcCYTzX (ORCPT ); Fri, 25 Mar 2016 15:55:23 -0400 X-IronPort-AV: E=Sophos;i="5.24,392,1454976000"; d="scan'208";a="76614953" From: Ulises Brindis Cc: Ulises Brindis , Zhang Rui , Eduardo Valentin , linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] thermal: of: fix cleanup when building a thermal zone Date: Fri, 25 Mar 2016 12:55:41 -0700 Message-Id: <1458935741-21355-1-git-send-email-brindisu@lab126.com> X-Mailer: git-send-email 1.7.9.5 To: unlisted-recipients:; (no To-header on input) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 849 Lines: 28 of_node_put is iterating through all terms in the tbps array even though the bind has failed. We need to only iterate through the terms that have already passed the binding step. Cc: Zhang Rui Cc: Eduardo Valentin Cc: linux-pm@vger.kernel.org Cc: linux-kernel@vger.kernel.org Signed-off-by: Ulises Brindis --- drivers/thermal/of-thermal.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/thermal/of-thermal.c b/drivers/thermal/of-thermal.c index 9043f8f..0f1c420 100644 --- a/drivers/thermal/of-thermal.c +++ b/drivers/thermal/of-thermal.c @@ -825,7 +825,7 @@ finish: return tz; free_tbps: - for (i = 0; i < tz->num_tbps; i++) + for (i = i - 1; i >= 0; i--) of_node_put(tz->tbps[i].cooling_device); kfree(tz->tbps); free_trips: -- 1.7.9.5