From patchwork Thu Apr 23 12:57:57 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sudip Mukherjee X-Patchwork-Id: 212240 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.6 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 72EDAC54FCB for ; Thu, 23 Apr 2020 12:58:01 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 41CFE2077D for ; Thu, 23 Apr 2020 12:58:01 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="WvdmeSTm" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728589AbgDWM6A (ORCPT ); Thu, 23 Apr 2020 08:58:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57732 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1728286AbgDWM6A (ORCPT ); Thu, 23 Apr 2020 08:58:00 -0400 Received: from mail-wm1-x342.google.com (mail-wm1-x342.google.com [IPv6:2a00:1450:4864:20::342]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E2B4AC08E934; Thu, 23 Apr 2020 05:57:59 -0700 (PDT) Received: by mail-wm1-x342.google.com with SMTP id u127so6448123wmg.1; Thu, 23 Apr 2020 05:57:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=dqaGCrrGdtqTHr8h7W7rgZUN4zoILX85Lt2ArDxobAw=; b=WvdmeSTm03f4OQVBbZ1iK+jbVgf/wF81xLfrlniB7emB2YICETx8QKNrBHjJ3D6B9S /kT220mEN9AJvYfMSrpreaeEy/xx6N3MHR3M8VBv44C1pQdCGOgVmWFPxZFaSEuLv1/p E4qk3+3tx+fACOucmXS+CoQzszk7ghP6MFuAjxXE1P7trrwLmBcLaPv2a2iSzAQERh53 CfbJmFQcQxfS6lUrjZ7mp87/3hJaDeYj1cErhJKhxoyzwDwkCMZQxbIlbOs+5ug72kkB aj1dUEhlyHaTL58Br7RnRA3TGbkQihUatFh7dsfmq9SxzjAFh1VoBG6P/rVrEw09vhV9 WXsQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=dqaGCrrGdtqTHr8h7W7rgZUN4zoILX85Lt2ArDxobAw=; b=IpC24l/tAOtchxTShUBvlBD8Btwwm3eGgGCFkmavfyswTTnN7n0tjirNVVo8JU6rSf TNZkQZROYDgrNXHGQ92RqcMKzn0ZVsFG095T6rlhYCc1GPOI9YGsvd5VAVENlmMiUUic q+QSigCtSse5GFrl06ex3dkLIgMsLFsrdk+6uobLmeydTZ96kEcBF/Hr0Lhv7Xt9B3Ox jln6LGuwZbm+4TDQXru9ClO5f1h5YcuQaBZ6b4+DkS8Hu8keoS4M6DpFziArRWqVvYeq mSJpxUnMnk50GBiPa6eAyGa/wiEr4P5PoGdES7o95i/jSn+wlZChijYTkZzG9U8YpbF5 LUGQ== X-Gm-Message-State: AGi0PuZ1/bkZ++VwCBWS5XuSSaKbXM3Srfv8NFaCmGesTNzhIvslSN5n 8ptEznObhuGqS4NoIzy5ufM= X-Google-Smtp-Source: APiQypJo4EyDiMeYphl9h0zQtMu+AdWMwzAH0KkyGB6bL0c5tSeXt3hvIJunfcz2O6eUi0LXihVJGA== X-Received: by 2002:a05:600c:2314:: with SMTP id 20mr3951028wmo.35.1587646678480; Thu, 23 Apr 2020 05:57:58 -0700 (PDT) Received: from debian.lan (host-84-13-17-86.opaltelecom.net. [84.13.17.86]) by smtp.gmail.com with ESMTPSA id 185sm4051252wmc.32.2020.04.23.05.57.57 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 23 Apr 2020 05:57:57 -0700 (PDT) From: Sudip Mukherjee To: Eduardo Valentin , Keerthy , Zhang Rui , Daniel Lezcano , Amit Kucheria Cc: linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, linux-omap@vger.kernel.org, Sudip Mukherjee Subject: [PATCH] thermal: ti-soc-thermal: avoid dereferencing ERR_PTR Date: Thu, 23 Apr 2020 13:57:57 +0100 Message-Id: <20200423125757.14057-1-sudipm.mukherjee@gmail.com> X-Mailer: git-send-email 2.11.0 Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org On error the function ti_bandgap_get_sensor_data() returns the error code in ERR_PTR() but we only checked if the return value is NULL or not. And, so we can dereference a error code inside ERR_PTR. Signed-off-by: Sudip Mukherjee --- drivers/thermal/ti-soc-thermal/ti-thermal-common.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/thermal/ti-soc-thermal/ti-thermal-common.c b/drivers/thermal/ti-soc-thermal/ti-thermal-common.c index d3e959d01606..1e2bf1f22dd1 100644 --- a/drivers/thermal/ti-soc-thermal/ti-thermal-common.c +++ b/drivers/thermal/ti-soc-thermal/ti-thermal-common.c @@ -196,7 +196,7 @@ int ti_thermal_remove_sensor(struct ti_bandgap *bgp, int id) data = ti_bandgap_get_sensor_data(bgp, id); - if (data && data->ti_thermal) { + if (!IS_ERR_OR_NULL(data) && data->ti_thermal) { if (data->our_zone) thermal_zone_device_unregister(data->ti_thermal); }