From patchwork Thu Sep 27 10:50:38 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sachin Kamat X-Patchwork-Id: 11753 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id A598623E57 for ; Thu, 27 Sep 2012 10:54:30 +0000 (UTC) Received: from mail-ie0-f180.google.com (mail-ie0-f180.google.com [209.85.223.180]) by fiordland.canonical.com (Postfix) with ESMTP id 48584A183F5 for ; Thu, 27 Sep 2012 10:54:30 +0000 (UTC) Received: by ieje10 with SMTP id e10so3802934iej.11 for ; Thu, 27 Sep 2012 03:54:29 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-forwarded-to:x-forwarded-for:delivered-to:received-spf:from:to:cc :subject:date:message-id:x-mailer:x-gm-message-state; bh=/iJbmCkDLaaytYWlv71rw0QBECdB6TaZrL26sRKY1Ok=; b=CiEzZCKBz/pdR+S8PTYjh2DGtgWIm5gpP+eGiYWbsfgLb37Lg7goCtX5tSU57JDFvZ RwpSY8k/L91xTg+Cw68wcBz12r+JPsdc5L4spbaHYx3J4Pc6yqv3ofusmLuGKSEBWjV6 t0YLqiR+/HTkBxLvd7tem5wWIu0VafwUKVbYG+48gf5Lj+vODtyYROzgOmPoWW1D7/1f WUy2i+4Km2yCygbO9c2JxK7D5G8XdHKMXVSfCQSxNk0imKzqZVHb8+mTYuROU4+lkwfB V/ukvkJPfxXgiAYiflSs41pMgICsiZktPdRVrGN47QKlqEBmX2bQdtx5nshhkHH03dZw twlQ== Received: by 10.50.160.165 with SMTP id xl5mr4371761igb.0.1348743269721; Thu, 27 Sep 2012 03:54:29 -0700 (PDT) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.50.184.232 with SMTP id ex8csp408799igc; Thu, 27 Sep 2012 03:54:28 -0700 (PDT) Received: by 10.68.224.161 with SMTP id rd1mr10648845pbc.49.1348743267806; Thu, 27 Sep 2012 03:54:27 -0700 (PDT) Received: from mail-pb0-f50.google.com (mail-pb0-f50.google.com [209.85.160.50]) by mx.google.com with ESMTPS id ou2si6876793pbb.110.2012.09.27.03.54.27 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 27 Sep 2012 03:54:27 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.160.50 is neither permitted nor denied by best guess record for domain of sachin.kamat@linaro.org) client-ip=209.85.160.50; Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.160.50 is neither permitted nor denied by best guess record for domain of sachin.kamat@linaro.org) smtp.mail=sachin.kamat@linaro.org Received: by pbcmd4 with SMTP id md4so962114pbc.37 for ; Thu, 27 Sep 2012 03:54:27 -0700 (PDT) Received: by 10.68.229.201 with SMTP id ss9mr10243404pbc.80.1348743267528; Thu, 27 Sep 2012 03:54:27 -0700 (PDT) Received: from localhost.localdomain ([115.113.119.130]) by mx.google.com with ESMTPS id b10sm3549736pav.17.2012.09.27.03.54.23 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 27 Sep 2012 03:54:26 -0700 (PDT) From: Sachin Kamat To: linux-kernel@vger.kernel.org Cc: amit.kachhap@linaro.org, rui.zhang@intel.com, sachin.kamat@linaro.org, patches@linaro.org Subject: [PATCH] thermal: Exynos: Fix NULL pointer dereference in exynos_unregister_thermal() Date: Thu, 27 Sep 2012 16:20:38 +0530 Message-Id: <1348743038-26168-1-git-send-email-sachin.kamat@linaro.org> X-Mailer: git-send-email 1.7.4.1 X-Gm-Message-State: ALoCoQk1aNDcxGrmJjqFbnkuaLOQr7Bwh3Rd7Mkk73NhYpOGIjObjOg91I8zQyTuZiVRxyD/dZpJ exynos_unregister_thermal() is functional only when 'th_zone' is not NULL (ensured by the NULL checks). However, in the event it is NULL, it gets dereferenced in the for loop. This patch fixes this issue. Signed-off-by: Sachin Kamat --- drivers/thermal/exynos_thermal.c | 7 +++++-- 1 files changed, 5 insertions(+), 2 deletions(-) diff --git a/drivers/thermal/exynos_thermal.c b/drivers/thermal/exynos_thermal.c index 4b203b6..4997a3a 100644 --- a/drivers/thermal/exynos_thermal.c +++ b/drivers/thermal/exynos_thermal.c @@ -475,11 +475,14 @@ static void exynos_unregister_thermal(void) { int i; - if (th_zone && th_zone->therm_dev) + if (!th_zone) + return; + + if (th_zone->therm_dev) thermal_zone_device_unregister(th_zone->therm_dev); for (i = 0; i < th_zone->cool_dev_size; i++) { - if (th_zone && th_zone->cool_dev[i]) + if (th_zone->cool_dev[i]) cpufreq_cooling_unregister(th_zone->cool_dev[i]); }