From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752174AbcFFQzD (ORCPT ); Mon, 6 Jun 2016 12:55:03 -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 X-PGP-Universal: processed; by hqnvupgp07.nvidia.com on Mon, 06 Jun 2016 09:51:56 -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 Content-Type: text/plain Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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++) { -- 1.9.1