From patchwork Wed Sep 24 08:27:12 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lukasz Majewski X-Patchwork-Id: 4962541 X-Patchwork-Delegate: rui.zhang@intel.com Return-Path: X-Original-To: patchwork-linux-pm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id EF038BEEA5 for ; Wed, 24 Sep 2014 08:28:49 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 1CCAC20265 for ; Wed, 24 Sep 2014 08:28:49 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id DE0F0200D5 for ; Wed, 24 Sep 2014 08:28:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752982AbaIXI15 (ORCPT ); Wed, 24 Sep 2014 04:27:57 -0400 Received: from mailout2.samsung.com ([203.254.224.25]:27973 "EHLO mailout2.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753858AbaIXI1y (ORCPT ); Wed, 24 Sep 2014 04:27:54 -0400 Received: from epcpsbgm2.samsung.com (epcpsbgm2 [203.254.230.27]) by mailout2.samsung.com (Oracle Communications Messaging Server 7u4-24.01(7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0NCE00M0SCUGRHE0@mailout2.samsung.com>; Wed, 24 Sep 2014 17:27:52 +0900 (KST) X-AuditID: cbfee61b-f79d76d0000024d6-b6-54228088c2ae Received: from epmmp1.local.host ( [203.254.227.16]) by epcpsbgm2.samsung.com (EPCPMTA) with SMTP id 6D.AE.09430.88082245; Wed, 24 Sep 2014 17:27:52 +0900 (KST) Received: from mcdsrvbld02.digital.local ([106.116.37.23]) by mmp1.samsung.com (Oracle Communications Messaging Server 7u4-24.01 (7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTPA id <0NCE00FDSCTFY620@mmp1.samsung.com>; Wed, 24 Sep 2014 17:27:52 +0900 (KST) From: Lukasz Majewski To: Zhang Rui , Eduardo Valentin Cc: Linux PM list , Lukasz Majewski , Bartlomiej Zolnierkiewicz , linux-kernel@vger.kernel.org, Lukasz Majewski Subject: [PATCH 3/3] thermal: core: fix: Check return code of the ->get_max_state() callback Date: Wed, 24 Sep 2014 10:27:12 +0200 Message-id: <1411547232-21493-4-git-send-email-l.majewski@samsung.com> X-Mailer: git-send-email 1.7.10.4 In-reply-to: <1411547232-21493-1-git-send-email-l.majewski@samsung.com> References: <1411547232-21493-1-git-send-email-l.majewski@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprMLMWRmVeSWpSXmKPExsVy+t9jAd2OBqUQg0PdPBYbZ6xntZh/5Rqr xZtH3BZvHm5mtLi8aw6bxefeI4wWTx72sTmwe+ycdZfdY/Gel0we66a9Zfbo27KK0ePzJrkA 1igum5TUnMyy1CJ9uwSujCWX/zAWLOWs+HD8GEsD43X2LkZODgkBE4kbM+axQNhiEhfurWfr YuTiEBJYxCjROrWLCcLpYpLovrwcrIpNQE/i892nQAkODhEBb4ktazhAapgFbjBKTOmfzARS IywQJzH36UQwm0VAVeLWt0mMIDavgJvEsR9bobYpSnQ/m8AGYnMKuEvc/P0M7CIhoJqDvw6y T2DkXcDIsIpRNLUguaA4KT3XSK84Mbe4NC9dLzk/dxMjOKieSe9gXNVgcYhRgINRiYd3grhS iBBrYllxZe4hRgkOZiUR3hOlQCHelMTKqtSi/Pii0pzU4kOM0hwsSuK8B1utA4UE0hNLUrNT UwtSi2CyTBycUg2My4seJgkt9zhey7aM57PmBZtbV+p+mXS5n9E26spXPPU6XmBrvRRDQcCW F5tbrx1Lm83mtOhKimX8uZzoqE/8+nMi5X0lEny1j0z8e2/eQesnGUKHuDrtDU78sTD5dDBF cctKq2eCB8zFbFd9Wsa8d/HXkzzlVRufe930eOB+5NSJVtWzwcy8SizFGYmGWsxFxYkAV+Lv nSYCAAA= 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.6 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 Without this check it was possible to execute cooling device binding code even when wrong max cooling state was read. Signed-off-by: Lukasz Majewski Acked-by: Eduardo Valentin --- drivers/thermal/thermal_core.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/thermal/thermal_core.c b/drivers/thermal/thermal_core.c index 747618a..8a4dc35 100644 --- a/drivers/thermal/thermal_core.c +++ b/drivers/thermal/thermal_core.c @@ -928,7 +928,7 @@ int thermal_zone_bind_cooling_device(struct thermal_zone_device *tz, struct thermal_zone_device *pos1; struct thermal_cooling_device *pos2; unsigned long max_state = 0; - int result; + int result, ret; if (trip >= tz->trips || (trip < 0 && trip != THERMAL_TRIPS_NONE)) return -EINVAL; @@ -945,7 +945,9 @@ int thermal_zone_bind_cooling_device(struct thermal_zone_device *tz, if (tz != pos1 || cdev != pos2) return -EINVAL; - cdev->ops->get_max_state(cdev, &max_state); + ret = cdev->ops->get_max_state(cdev, &max_state); + if (ret) + return ret; /* lower default 0, upper default max_state */ lower = lower == THERMAL_NO_LIMIT ? 0 : lower;