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: 10285451 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id E1AEC60291 for ; Thu, 15 Mar 2018 18:08:30 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D256C28BEA for ; Thu, 15 Mar 2018 18:08:30 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C714528BEC; Thu, 15 Mar 2018 18:08:30 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3DD7228BEA for ; Thu, 15 Mar 2018 18:08:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752025AbeCOSIa (ORCPT ); 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-hwmon-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-hwmon@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 Acked-by: Guenter Roeck --- 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 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: