From patchwork Thu Nov 13 17:02:44 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lukasz Majewski X-Patchwork-Id: 5299361 X-Patchwork-Delegate: eduardo.valentin@ti.com 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.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 13EFA9F2F1 for ; Thu, 13 Nov 2014 17:04:52 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 8BF6120212 for ; Thu, 13 Nov 2014 17:04:46 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 8D3DD2021A for ; Thu, 13 Nov 2014 17:04:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933398AbaKMRDq (ORCPT ); Thu, 13 Nov 2014 12:03:46 -0500 Received: from mailout3.samsung.com ([203.254.224.33]:50854 "EHLO mailout3.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933395AbaKMRDm (ORCPT ); Thu, 13 Nov 2014 12:03:42 -0500 Received: from epcpsbgm2.samsung.com (epcpsbgm2 [203.254.230.27]) by mailout3.samsung.com (Oracle Communications Messaging Server 7u4-24.01(7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0NEZ00BS3M25R080@mailout3.samsung.com>; Fri, 14 Nov 2014 02:03:41 +0900 (KST) X-AuditID: cbfee61b-f79d76d0000024d6-e0-5464e46d7779 Received: from epmmp2 ( [203.254.227.17]) by epcpsbgm2.samsung.com (EPCPMTA) with SMTP id A6.EF.09430.D64E4645; Fri, 14 Nov 2014 02:03:41 +0900 (KST) Received: from mcdsrvbld02.digital.local ([106.116.37.23]) by mmp2.samsung.com (Oracle Communications Messaging Server 7u4-24.01 (7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTPA id <0NEZ00JCWM0NNZ60@mmp2.samsung.com>; Fri, 14 Nov 2014 02:03:41 +0900 (KST) From: Lukasz Majewski To: Eduardo Valentin , Zhang Rui Cc: Ezequiel Garcia , Kuninori Morimoto , Linux PM list , Vincenzo Frascino , Bartlomiej Zolnierkiewicz , Lukasz Majewski , Nobuhiro Iwamatsu , Mikko Perttunen , Stephen Warren , Thierry Reding , Alexandre Courbot , linux-tegra@vger.kernel.org, linux-kernel@vger.kernel.org, Lukasz Majewski Subject: [PATCH 7/8] thermal:core:fix: Initialize the max_state variable to 0 Date: Thu, 13 Nov 2014 18:02:44 +0100 Message-id: <1415898165-27406-8-git-send-email-l.majewski@samsung.com> X-Mailer: git-send-email 1.7.10.4 In-reply-to: <1415898165-27406-1-git-send-email-l.majewski@samsung.com> References: <1411547232-21493-1-git-send-email-l.majewski@samsung.com> <1415898165-27406-1-git-send-email-l.majewski@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrHLMWRmVeSWpSXmKPExsVy+t9jQd3cJykhBqtnCllsnLGe1WL+lWus FqdPLWC1OPfqEYvF2+Zii1eHdzFavHnEbfHm4WZGi8u75rBZfO49wmjR+WUWm8WDq9PYLJ48 7GOzeHWwjcXi5655LBbHTsxgdRDweLLpIqPHzll32T0W73nJ5LFu2ltmjwOTz7F69Da/Y/P4 dmYii0ffllWMHk9/7GX2+LxJzmPj3NAA7igum5TUnMyy1CJ9uwSujNYllxkLlnNXNF7ewt7A uJezi5GTQ0LAROLrxL2sELaYxIV769m6GLk4hASmM0ps673PCuF0MUn0H3vFBFLFJqAn8fnu UzBbRMBb4vW+6YwgRcwCr1kkDv1oYAdJCAv4SnQvb2cDsVkEVCUerugAs3kF3CQ6mn6zQKxT lOh+NgEszingLnH0xCd2iG3NjBKf+2axTmDkXcDIsIpRNLUguaA4KT3XSK84Mbe4NC9dLzk/ dxMjONSfSe9gXNVgcYhRgINRiYf3BUtKiBBrYllxZe4hRgkOZiUR3ur7QCHelMTKqtSi/Pii 0pzU4kOM0hwsSuK8B1utA4UE0hNLUrNTUwtSi2CyTBycUg2MQqKSX9J1vR7Znvywd2auc6nu SfOS4/e7RVu6j/AUW5XdWCftqfnvm2vyxucq91IYGJemu1+UPe6gWW/FnB6hbmm2rjhajNNs lbStj6rPvdsKjEdYghqKD/uf2FK79HpQrFPrLZ8/93QNJuSxHJgo9dlmjU3hvUm33kzkue25 pTY3/+LdNwxKLMUZiYZazEXFiQCbR2xncQIAAA== 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.9 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 Pointer to the uninitialized max_state variable is passed to get the maximal cooling state. For CPU cooling device (cpu_cooling.c) the cpufreq_get_max_state() is called, which even when error occurs will return the max_state variable unchanged. Since error for ->get_max_state() is not checked, the automatically allocated value of max_state is used for (upper > max_state) comparison. For any possible max_state value it is very unlikely that it will be less than upper. As a consequence, the cooling device is bind even without the backed cpufreq table initialized. This initialization will prevent from accidental binding trip points to cpu freq cooling frequencies when cpufreq driver itself is not yet fully initialized. Signed-off-by: Lukasz Majewski --- drivers/thermal/thermal_core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/thermal/thermal_core.c b/drivers/thermal/thermal_core.c index 43b9070..413daa4 100644 --- a/drivers/thermal/thermal_core.c +++ b/drivers/thermal/thermal_core.c @@ -927,7 +927,7 @@ int thermal_zone_bind_cooling_device(struct thermal_zone_device *tz, struct thermal_instance *pos; struct thermal_zone_device *pos1; struct thermal_cooling_device *pos2; - unsigned long max_state; + unsigned long max_state = 0; int result; if (trip >= tz->trips || (trip < 0 && trip != THERMAL_TRIPS_NONE))