From patchwork Tue Oct 16 11:44:47 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hongbo Zhang X-Patchwork-Id: 1600311 Return-Path: X-Original-To: patchwork-linux-pm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork2.kernel.org (Postfix) with ESMTP id 879D9E00AF for ; Tue, 16 Oct 2012 11:46:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754499Ab2JPLqm (ORCPT ); Tue, 16 Oct 2012 07:46:42 -0400 Received: from mail-pb0-f46.google.com ([209.85.160.46]:40059 "EHLO mail-pb0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753885Ab2JPLql (ORCPT ); Tue, 16 Oct 2012 07:46:41 -0400 Received: by mail-pb0-f46.google.com with SMTP id rr4so5898759pbb.19 for ; Tue, 16 Oct 2012 04:46:41 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references :x-gm-message-state; bh=g3oOPhs0FKOf4mHjesLiy1aQcpQe6Wj3ecZ7LJN24/Q=; b=oLqBJ4g+pwgx1sIEmiUxCYfveTwzL2Z6Yov9YCG3AHPmcSFJOiXHMfxKHIsm11kdVQ 7wJEVq8YEM6/QCtyN4STSKpigA/vJ+WR2kvZ6gLvoDH2XriEjc4vdU3NwLH9rqec4IUp AGHvIi1qg4TTe/jELLtgU5UGedQY0cppYsvsnf6WHaEZh0uwHX/PakCsIRBXJoZxS363 D334iaATXlhCtXKF1TfuwN3zYpWM1CHXwmvzYKmW2tSWtGpDzZDySiRJZOszRfxm/Wbc 5+1iQFGX2b6IGUO1IZxn80lzt2FFbtcZrbzhdhVNT7TbTlWXFsRrpmw0Eumpk7SVve5T Rkdg== Received: by 10.68.130.198 with SMTP id og6mr45696517pbb.163.1350388001554; Tue, 16 Oct 2012 04:46:41 -0700 (PDT) Received: from stebjsxu0148.bjs.st.com ([124.127.135.94]) by mx.google.com with ESMTPS id pv9sm10667709pbb.67.2012.10.16.04.46.33 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 16 Oct 2012 04:46:41 -0700 (PDT) From: "hongbo.zhang" To: linaro-dev@lists.linaro.org, linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org Cc: patches@linaro.org, linaro-kernel@lists.linaro.org, STEricsson_nomadik_linux@list.st.com, kernel@igloocommunity.org, "hongbo.zhang" Subject: [PATCH 3/5] Thermal: fix empty list checking method. Date: Tue, 16 Oct 2012 19:44:47 +0800 Message-Id: <1350387889-15324-4-git-send-email-hongbo.zhang@linaro.com> X-Mailer: git-send-email 1.7.11.3 In-Reply-To: <1350387889-15324-1-git-send-email-hongbo.zhang@linaro.com> References: <1350387889-15324-1-git-send-email-hongbo.zhang@linaro.com> X-Gm-Message-State: ALoCoQlRMDMU3iwznWWUaATbslHQsPg3Ze8omuRdf0e6dQC/OPcVAXV3eGNbciokgZQoTdSS6Lvq Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org From: "hongbo.zhang" Is is not reliable to check the list entry pointer after list_for_each_entry loop, list_empty should be used instead. Signed-off-by: hongbo.zhang Reviewed-by: Viresh Kumar --- drivers/thermal/cpu_cooling.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/thermal/cpu_cooling.c b/drivers/thermal/cpu_cooling.c index b6b4c2a..d196230 100644 --- a/drivers/thermal/cpu_cooling.c +++ b/drivers/thermal/cpu_cooling.c @@ -247,12 +247,13 @@ static int cpufreq_get_max_state(struct thermal_cooling_device *cdev, struct cpufreq_frequency_table *table; mutex_lock(&cooling_cpufreq_lock); + if (list_empty(&cooling_cpufreq_list)) + goto return_get_max_state; + list_for_each_entry(cpufreq_device, &cooling_cpufreq_list, node) { if (cpufreq_device && cpufreq_device->cool_dev == cdev) break; } - if (cpufreq_device == NULL) - goto return_get_max_state; maskPtr = &cpufreq_device->allowed_cpus; cpu = cpumask_any(maskPtr);