From patchwork Sat Mar 9 07:31:34 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Axel Lin X-Patchwork-Id: 2241211 X-Patchwork-Delegate: rui.zhang@intel.com 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 5D921DF2F2 for ; Sat, 9 Mar 2013 07:31:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755571Ab3CIHbp (ORCPT ); Sat, 9 Mar 2013 02:31:45 -0500 Received: from mail-ie0-f173.google.com ([209.85.223.173]:58388 "EHLO mail-ie0-f173.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754891Ab3CIHbp (ORCPT ); Sat, 9 Mar 2013 02:31:45 -0500 Received: by mail-ie0-f173.google.com with SMTP id 9so2989895iec.32 for ; Fri, 08 Mar 2013 23:31:44 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-received:message-id:subject:from:to:cc:date:content-type:x-mailer :content-transfer-encoding:mime-version:x-gm-message-state; bh=VkueVcd0bcTM+5B1eL2THpqz+GHgYiQytSqNfJDYAGA=; b=htBDdqCTYWm37CP5tZcZJ9FnDKpI5og8iJQYPchRmfrGE6+R29rriTvh+5GQzY4x4/ mnobu8+uR2FYyoHMYzT98x+wjeZ8c0iWyy0C1Gr7vWU5MZuQhhNWqx58guk2qeZL2vaN MZwgjkVAZos/fpyWBUd+ESrO9rp54D99YGr9VUfJDj9D7y8d6jBTuqjq/btaobosUi/O kSQnQRGBVxWkf/ULg8gav7Rlvr55fNL25OiZpjPtBGRUv6rOZqO7CilymeWkYRKxO+RX gwXbKql2yhPSPj+gpWSYRYBmx/grEdTQNH69bBEop4ctM6DPTRALD6HogWx80n10bHbf LiPA== X-Received: by 10.50.190.164 with SMTP id gr4mr1601963igc.19.1362814304580; Fri, 08 Mar 2013 23:31:44 -0800 (PST) Received: from [192.168.0.102] (218-173-169-152.dynamic.hinet.net. [218.173.169.152]) by mx.google.com with ESMTPS id g6sm3174193ign.4.2013.03.08.23.31.40 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 08 Mar 2013 23:31:43 -0800 (PST) Message-ID: <1362814294.30718.1.camel@phoenix> Subject: [PATCH] thermal: db8500: Fix missing mutex_unlock() in probe error paths From: Axel Lin To: Zhang Rui Cc: Hongbo Zhang , Viresh Kumar , Francesco Lavra , linux-pm@vger.kernel.org Date: Sat, 09 Mar 2013 15:31:34 +0800 X-Mailer: Evolution 3.2.3-0ubuntu6 Mime-Version: 1.0 X-Gm-Message-State: ALoCoQkr04i0ZjpLiADAwj/VRng1TTAkLp79rQACVGM/Yo3/QyXTdxJn1PWCwMDlyXQbSTXx1juM Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org Fix missing mutex_unlock() in probe error paths. Also fix checking return value of thermal_zone_device_register(). thermal_zone_device_register() returns ERR_PTR on error, thus use IS_ERR rather than IS_ERR_OR_NULL to check return value. This patch also includes a few cleanup to remove unnecessary initialization for *pzone, *ptrips and ret variables. Signed-off-by: Axel Lin --- drivers/thermal/db8500_thermal.c | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/drivers/thermal/db8500_thermal.c b/drivers/thermal/db8500_thermal.c index 61ce60a..6344084 100644 --- a/drivers/thermal/db8500_thermal.c +++ b/drivers/thermal/db8500_thermal.c @@ -390,10 +390,10 @@ static inline struct db8500_thsens_platform_data* static int db8500_thermal_probe(struct platform_device *pdev) { - struct db8500_thermal_zone *pzone = NULL; - struct db8500_thsens_platform_data *ptrips = NULL; + struct db8500_thermal_zone *pzone; + struct db8500_thsens_platform_data *ptrips; struct device_node *np = pdev->dev.of_node; - int low_irq, high_irq, ret = 0; + int low_irq, high_irq, ret; unsigned long dft_low, dft_high; if (np) @@ -419,7 +419,8 @@ static int db8500_thermal_probe(struct platform_device *pdev) low_irq = platform_get_irq_byname(pdev, "IRQ_HOTMON_LOW"); if (low_irq < 0) { dev_err(&pdev->dev, "Get IRQ_HOTMON_LOW failed.\n"); - return low_irq; + ret = low_irq; + goto out_unlock; } ret = devm_request_threaded_irq(&pdev->dev, low_irq, NULL, @@ -427,13 +428,14 @@ static int db8500_thermal_probe(struct platform_device *pdev) "dbx500_temp_low", pzone); if (ret < 0) { dev_err(&pdev->dev, "Failed to allocate temp low irq.\n"); - return ret; + goto out_unlock; } high_irq = platform_get_irq_byname(pdev, "IRQ_HOTMON_HIGH"); if (high_irq < 0) { dev_err(&pdev->dev, "Get IRQ_HOTMON_HIGH failed.\n"); - return high_irq; + ret = high_irq; + goto out_unlock; } ret = devm_request_threaded_irq(&pdev->dev, high_irq, NULL, @@ -441,15 +443,16 @@ static int db8500_thermal_probe(struct platform_device *pdev) "dbx500_temp_high", pzone); if (ret < 0) { dev_err(&pdev->dev, "Failed to allocate temp high irq.\n"); - return ret; + goto out_unlock; } pzone->therm_dev = thermal_zone_device_register("db8500_thermal_zone", ptrips->num_trips, 0, pzone, &thdev_ops, NULL, 0, 0); - if (IS_ERR_OR_NULL(pzone->therm_dev)) { + if (IS_ERR(pzone->therm_dev)) { dev_err(&pdev->dev, "Register thermal zone device failed.\n"); - return PTR_ERR(pzone->therm_dev); + ret = PTR_ERR(pzone->therm_dev); + goto out_unlock; } dev_info(&pdev->dev, "Thermal zone device registered.\n"); @@ -461,9 +464,11 @@ static int db8500_thermal_probe(struct platform_device *pdev) platform_set_drvdata(pdev, pzone); pzone->mode = THERMAL_DEVICE_ENABLED; + +out_unlock: mutex_unlock(&pzone->th_lock); - return 0; + return ret; } static int db8500_thermal_remove(struct platform_device *pdev)