From patchwork Thu Apr 15 18:52:31 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: srinivas pandruvada X-Patchwork-Id: 12205989 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=-16.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,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 63A2BC433ED for ; Thu, 15 Apr 2021 18:52:36 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 3F98561152 for ; Thu, 15 Apr 2021 18:52:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234359AbhDOSw6 (ORCPT ); Thu, 15 Apr 2021 14:52:58 -0400 Received: from mga04.intel.com ([192.55.52.120]:31157 "EHLO mga04.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234101AbhDOSw5 (ORCPT ); Thu, 15 Apr 2021 14:52:57 -0400 IronPort-SDR: XvI4ysctFejX4uyz5VK18NhRSsFJVb7k33FunaIfLnZgx1/d0Pde5HgvvU8JF0qmWv2cSRyQMJ Y5mMsLcCgyHA== X-IronPort-AV: E=McAfee;i="6200,9189,9955"; a="192792351" X-IronPort-AV: E=Sophos;i="5.82,225,1613462400"; d="scan'208";a="192792351" Received: from orsmga006.jf.intel.com ([10.7.209.51]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Apr 2021 11:52:34 -0700 IronPort-SDR: WB2x6z6CCoH5XIEzorYma2EX9jtZ2l+8i7JM5jECwf9LC/1rItW8KiDCtEs7hzjz6VxZV7qu7i zPb49kjLhHeA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.82,225,1613462400"; d="scan'208";a="384108663" Received: from spandruv-desk.jf.intel.com ([10.54.75.21]) by orsmga006.jf.intel.com with ESMTP; 15 Apr 2021 11:52:33 -0700 From: Srinivas Pandruvada To: jikos@kernel.org, jic23@kernel.org, benjamin.tissoires@redhat.com Cc: jiapeng.chong@linux.alibaba.com, linux-input@vger.kernel.org, linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org, Srinivas Pandruvada Subject: [PATCH 1/2] HID: hid-sensor-hub: Return error for hid_set_field() failure Date: Thu, 15 Apr 2021 11:52:31 -0700 Message-Id: <20210415185232.2617398-1-srinivas.pandruvada@linux.intel.com> X-Mailer: git-send-email 2.25.4 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org In the function sensor_hub_set_feature(), return error when hid_set_field() fails. Signed-off-by: Srinivas Pandruvada Acked-by: Jonathan Cameron --- drivers/hid/hid-sensor-hub.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/drivers/hid/hid-sensor-hub.c b/drivers/hid/hid-sensor-hub.c index 3dd7d3246737..f9983145d4e7 100644 --- a/drivers/hid/hid-sensor-hub.c +++ b/drivers/hid/hid-sensor-hub.c @@ -210,16 +210,21 @@ int sensor_hub_set_feature(struct hid_sensor_hub_device *hsdev, u32 report_id, buffer_size = buffer_size / sizeof(__s32); if (buffer_size) { for (i = 0; i < buffer_size; ++i) { - hid_set_field(report->field[field_index], i, - (__force __s32)cpu_to_le32(*buf32)); + ret = hid_set_field(report->field[field_index], i, + (__force __s32)cpu_to_le32(*buf32)); + if (ret) + goto done_proc; + ++buf32; } } if (remaining_bytes) { value = 0; memcpy(&value, (u8 *)buf32, remaining_bytes); - hid_set_field(report->field[field_index], i, - (__force __s32)cpu_to_le32(value)); + ret = hid_set_field(report->field[field_index], i, + (__force __s32)cpu_to_le32(value)); + if (ret) + goto done_proc; } hid_hw_request(hsdev->hdev, report, HID_REQ_SET_REPORT); hid_hw_wait(hsdev->hdev); From patchwork Thu Apr 15 18:52:32 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: srinivas pandruvada X-Patchwork-Id: 12205991 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=-16.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=unavailable 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 0E2A8C43461 for ; Thu, 15 Apr 2021 18:52:37 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id DB10761152 for ; Thu, 15 Apr 2021 18:52:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234624AbhDOSw7 (ORCPT ); Thu, 15 Apr 2021 14:52:59 -0400 Received: from mga04.intel.com ([192.55.52.120]:31157 "EHLO mga04.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234130AbhDOSw6 (ORCPT ); Thu, 15 Apr 2021 14:52:58 -0400 IronPort-SDR: iCQog4TSMRZgcB/LMvbyZy8VkTsQayTTur8j5c2Ogt0EpUq2BMBTK4iPvznEQ0Tu5G5ROAZxnd XNJoU0PcuKqg== X-IronPort-AV: E=McAfee;i="6200,9189,9955"; a="192792352" X-IronPort-AV: E=Sophos;i="5.82,225,1613462400"; d="scan'208";a="192792352" Received: from orsmga006.jf.intel.com ([10.7.209.51]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Apr 2021 11:52:34 -0700 IronPort-SDR: DFBCUJEtDxUksTKRKNaAlzx0BVuxqACJB5p62qimFIR67QXky9d9LfVyRQsFMzqUCKGbsjveTz 8urLasqI4jbg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.82,225,1613462400"; d="scan'208";a="384108664" Received: from spandruv-desk.jf.intel.com ([10.54.75.21]) by orsmga006.jf.intel.com with ESMTP; 15 Apr 2021 11:52:33 -0700 From: Srinivas Pandruvada To: jikos@kernel.org, jic23@kernel.org, benjamin.tissoires@redhat.com Cc: jiapeng.chong@linux.alibaba.com, linux-input@vger.kernel.org, linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org, Srinivas Pandruvada , Abaci Robot Subject: [PATCH 2/2] HID: hid-sensor-custom: Process failure of sensor_hub_set_feature() Date: Thu, 15 Apr 2021 11:52:32 -0700 Message-Id: <20210415185232.2617398-2-srinivas.pandruvada@linux.intel.com> X-Mailer: git-send-email 2.25.4 In-Reply-To: <20210415185232.2617398-1-srinivas.pandruvada@linux.intel.com> References: <20210415185232.2617398-1-srinivas.pandruvada@linux.intel.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org When user modifies a custom feature value and sensor_hub_set_feature() fails, return error. Reported-by: Abaci Robot Signed-off-by: Srinivas Pandruvada --- Replaces patch: HID: hid-sensor-custom: remove useless variable by Jiapeng Chong drivers/hid/hid-sensor-custom.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/hid/hid-sensor-custom.c b/drivers/hid/hid-sensor-custom.c index 2628bc53ed80..58b54b127cdf 100644 --- a/drivers/hid/hid-sensor-custom.c +++ b/drivers/hid/hid-sensor-custom.c @@ -406,6 +406,8 @@ static ssize_t store_value(struct device *dev, struct device_attribute *attr, report_id; ret = sensor_hub_set_feature(sensor_inst->hsdev, report_id, index, sizeof(value), &value); + if (ret) + return ret; } else return -EINVAL;