From patchwork Thu Mar 15 18:08:19 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sudeep Holla X-Patchwork-Id: 131837 Delivered-To: patch@linaro.org Received: by 10.46.84.17 with SMTP id i17csp1437880ljb; Thu, 15 Mar 2018 11:08:35 -0700 (PDT) X-Google-Smtp-Source: AG47ELtTvxuKPHhuCL13TbDccMMYF8QvHex04QGTBdohBlPByv/ukbnRLqd0hqRI/yD8zKpBUXqa X-Received: by 10.99.132.72 with SMTP id k69mr7416109pgd.367.1521137314845; Thu, 15 Mar 2018 11:08:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521137314; cv=none; d=google.com; s=arc-20160816; b=UBpn58INUNcTWoW1OSHAVqEhhS9PUWxcyKuK4T/hKEjCgx4rA1VIm3RvQg2cGDc4xm 5v+UsTs/WKBE05IqdiO481ANB181Cu9l2VuqDV89l0SeNPwvnu5Qax0t3LEQxxiRR4Ym mAulzyDfyv7/rYkubxMiO5U8GjPLJ8CpU3xzogNP8p32ZMe2VE+hh+MtonGiNafI/B53 3upQq4RjlnSAQhJ+cs3wB6ggVUcjE0zUPMKaZeL6UWM9+SEmnZ9NBOCpeHt3tEbeX7mk WbFEV9weY6+oYMQH++pWQ0XT40dLA6Z59b8jleooeIxMgH97sojCJLDqAxvzabpFmorr BCRg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :arc-authentication-results; bh=r5Mr8KZ/AzZPXuOKZrptddELcre6xVNGifYvoItiLcE=; b=f+Rxslta+V86reDg9sz51bI6qmZ7U1ezQkYRcu+gGQMGg4qtyCbAkZwrYY53/dPWIy 4sCHBqk/rK4lcX1KAH4UbM8lYXKlGhJa3+bjmG8fFuXAzTg8M6J2r9pWEjh0122y7qrz MERQAouDib4KoO/lJ8sb03TxfUjH0Dy+EkwBl3ZWAkWWCpPC39hoaFEMixy2UnTRUGun Czm36c3P4fArZ7ldffRWCaPIWtIlP/FC9cc+l/VP8aUB2tZdGuH+fj6rvYfqoD2Ph6BW JH0Hle7GeAQkcckGvdJgdmaXFMjQ5pnbEJpxZZYt6W533P8GLBLZuPDIluP9QEC97E5z MmOw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n2-v6si4578506pls.497.2018.03.15.11.08.34; Thu, 15 Mar 2018 11:08:34 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752587AbeCOSIa (ORCPT + 28 others); Thu, 15 Mar 2018 14:08:30 -0400 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:45502 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751466AbeCOSI3 (ORCPT ); Thu, 15 Mar 2018 14:08:29 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 2401A1435; Thu, 15 Mar 2018 11:08:29 -0700 (PDT) Received: from e107155-lin.cambridge.arm.com (unknown [10.1.210.28]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 0ADFF3F25D; Thu, 15 Mar 2018 11:08:27 -0700 (PDT) From: Sudeep Holla To: linux-kernel@vger.kernel.org Cc: Sudeep Holla , Dan Carpenter , Guenter Roeck , linux-hwmon@vger.kernel.org Subject: [PATCH -next] hwmon: (scmi) return -EINVAL when sensor information is unavailable Date: Thu, 15 Mar 2018 18:08:19 +0000 Message-Id: <1521137299-31363-1-git-send-email-sudeep.holla@arm.com> X-Mailer: git-send-email 2.7.4 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Passing NULL pointer to PTR_ERR will result in return value of 0 indicating success which is clearly not what it is intended here. This patch returns -EINVAL instead when the sensor information is not available. Fixes: b23688aefb8b ("hwmon: add support for sensors exported via ARM SCMI") Reported-by: Dan Carpenter Cc: Guenter Roeck Cc: linux-hwmon@vger.kernel.org Signed-off-by: Sudeep Holla --- drivers/hwmon/scmi-hwmon.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) Hi Guenter, I will try to push this via ARM-SoC if possible before v4.17 merge window. So please provide Ack if you are fine. Regards, Sudeep -- 2.7.4 Acked-by: Guenter Roeck diff --git a/drivers/hwmon/scmi-hwmon.c b/drivers/hwmon/scmi-hwmon.c index 32e750373ced..363bf56eb0f2 100644 --- a/drivers/hwmon/scmi-hwmon.c +++ b/drivers/hwmon/scmi-hwmon.c @@ -138,7 +138,7 @@ static int scmi_hwmon_probe(struct scmi_device *sdev) for (i = 0; i < nr_sensors; i++) { sensor = handle->sensor_ops->info_get(handle, i); if (!sensor) - return PTR_ERR(sensor); + return -EINVAL; switch (sensor->type) { case TEMPERATURE_C: