From patchwork Mon Jun 6 16:50:23 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rhyland Klein X-Patchwork-Id: 9158797 X-Patchwork-Delegate: rui.zhang@intel.com Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 1099960573 for ; Mon, 6 Jun 2016 16:52:02 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0219C26E5D for ; Mon, 6 Jun 2016 16:52:02 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id EAB912834C; Mon, 6 Jun 2016 16:52:01 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 73B5626E5D for ; Mon, 6 Jun 2016 16:52:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751304AbcFFQwA (ORCPT ); Mon, 6 Jun 2016 12:52:00 -0400 Received: from hqemgate15.nvidia.com ([216.228.121.64]:14055 "EHLO hqemgate15.nvidia.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751120AbcFFQv7 (ORCPT ); Mon, 6 Jun 2016 12:51:59 -0400 Received: from hqnvupgp08.nvidia.com (Not Verified[216.228.121.13]) by hqemgate15.nvidia.com id ; Mon, 06 Jun 2016 09:51:53 -0700 Received: from HQMAIL103.nvidia.com ([172.20.187.11]) by hqnvupgp08.nvidia.com (PGP Universal service); Mon, 06 Jun 2016 09:49:44 -0700 X-PGP-Universal: processed; by hqnvupgp08.nvidia.com on Mon, 06 Jun 2016 09:49:44 -0700 Received: from HQMAIL109.nvidia.com (172.20.187.15) by HQMAIL103.nvidia.com (172.20.187.11) with Microsoft SMTP Server (TLS) id 15.0.1130.7; Mon, 6 Jun 2016 16:51:53 +0000 Received: from HQMAIL103.nvidia.com (172.20.187.11) by HQMAIL109.nvidia.com (172.20.187.15) with Microsoft SMTP Server (TLS) id 15.0.1130.7; Mon, 6 Jun 2016 16:51:53 +0000 Received: from hqnvemgw02.nvidia.com (172.16.227.111) by HQMAIL103.nvidia.com (172.20.187.11) with Microsoft SMTP Server id 15.0.1130.7 via Frontend Transport; Mon, 6 Jun 2016 16:51:53 +0000 Received: from rklein-work.nvidia.com (Not Verified[10.2.68.50]) by hqnvemgw02.nvidia.com with Trustwave SEG (v7, 5, 5, 8150) id ; Mon, 06 Jun 2016 09:51:53 -0700 From: Rhyland Klein To: Zhang Rui , Eduardo Valentin CC: , , Rhyland Klein Subject: [PATCH 1/2] thermal: helpers: Check return value of get_temp Date: Mon, 6 Jun 2016 12:50:23 -0400 Message-ID: <1465231823-12384-1-git-send-email-rklein@nvidia.com> X-Mailer: git-send-email 1.9.1 X-NVConfidentiality: public MIME-Version: 1.0 Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Check the return value of get_temp, which can fail. If it does, then unlock and return the error code. Signed-off-by: Rhyland Klein --- drivers/thermal/thermal_helpers.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/thermal/thermal_helpers.c b/drivers/thermal/thermal_helpers.c index 5e1c160944c9..dc260749f8d6 100644 --- a/drivers/thermal/thermal_helpers.c +++ b/drivers/thermal/thermal_helpers.c @@ -90,6 +90,10 @@ int thermal_zone_get_temp(struct thermal_zone_device *tz, int *temp) mutex_lock(&tz->lock); ret = tz->ops->get_temp(tz, temp); + if (!ret) { + mutex_unlock(&tz->lock); + goto exit; + } if (IS_ENABLED(CONFIG_THERMAL_EMULATION) && tz->emul_temperature) { for (count = 0; count < tz->trips; count++) {