From patchwork Mon Jun 6 16:53:39 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rhyland Klein X-Patchwork-Id: 9158803 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 6B28760759 for ; Mon, 6 Jun 2016 16:55:05 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5BA6426E5D for ; Mon, 6 Jun 2016 16:55:05 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4FEA72834A; Mon, 6 Jun 2016 16:55:05 +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 D0E5E26E5D for ; Mon, 6 Jun 2016 16:55:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751893AbcFFQzC (ORCPT ); Mon, 6 Jun 2016 12:55:02 -0400 Received: from hqemgate16.nvidia.com ([216.228.121.65]:1522 "EHLO hqemgate16.nvidia.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751539AbcFFQzC (ORCPT ); Mon, 6 Jun 2016 12:55:02 -0400 Received: from hqnvupgp07.nvidia.com (Not Verified[216.228.121.13]) by hqemgate16.nvidia.com id ; Mon, 06 Jun 2016 09:54:55 -0700 Received: from HQHUB101.nvidia.com ([172.20.12.94]) by hqnvupgp07.nvidia.com (PGP Universal service); Mon, 06 Jun 2016 09:51:56 -0700 X-PGP-Universal: processed; by hqnvupgp07.nvidia.com on Mon, 06 Jun 2016 09:51:56 -0700 Received: from HQMAIL112.nvidia.com (172.18.146.18) by HQHUB101.nvidia.com (172.20.187.24) with Microsoft SMTP Server (TLS) id 8.3.406.0; Mon, 6 Jun 2016 09:55:00 -0700 Received: from HQMAIL106.nvidia.com (172.18.146.12) by HQMAIL112.nvidia.com (172.18.146.18) with Microsoft SMTP Server (TLS) id 15.0.1130.7; Mon, 6 Jun 2016 16:54:59 +0000 Received: from hqnvemgw01.nvidia.com (172.20.150.20) by HQMAIL106.nvidia.com (172.18.146.12) with Microsoft SMTP Server id 15.0.1130.7 via Frontend Transport; Mon, 6 Jun 2016 16:54:59 +0000 Received: from rklein-work.nvidia.com (Not Verified[10.2.68.50]) by hqnvemgw01.nvidia.com with Trustwave SEG (v7,5,5,8150) id ; Mon, 06 Jun 2016 09:54:59 -0700 From: Rhyland Klein To: Zhang Rui , Eduardo Valentin CC: , , Rhyland Klein Subject: [RESEND PATCH] thermal: helpers: Check return value of get_temp Date: Mon, 6 Jun 2016 12:53:39 -0400 Message-ID: <1465232019-12441-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++) {