From patchwork Thu Nov 17 12:13:26 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marcus Folkesson X-Patchwork-Id: 21617 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp369778wrr; Thu, 17 Nov 2022 04:27:19 -0800 (PST) X-Google-Smtp-Source: AA0mqf4czwiMbHfhcDRhMrgkSDkPkUy+5LqZo+CjdURoxsUbwBjxhLtCUcrY0FAv0jNw0eocMX20 X-Received: by 2002:a63:e609:0:b0:458:cfe7:8dd with SMTP id g9-20020a63e609000000b00458cfe708ddmr1721205pgh.548.1668688038968; Thu, 17 Nov 2022 04:27:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668688038; cv=none; d=google.com; s=arc-20160816; b=aFn/sabm/eVePAhrGsHwWHoKsVGrrRHD+KNYvPywKrv8WA9dxthFsI7JseClAwaxun Zwsr9GBjb4yIv3hFOg3o9Xl1iwwlazMvvTIftiHOPFwoKwEaiUl8LFVA/tsVROWPflJk M9SN0xufy5yz47/hbgDXdrcbbU40jknF9JXMw4L40VPqQjXRUIXjYZXGPy+vgJp2y2gL KjUexvCo85I4LIojf6n0DvgjkIuX/3FNB6+ITO0Sp1mB8wmH/gGHpO/e0er1lgvuMd1H rsJduPB/mH9Pu2A7+awXU0xh+rJEAfjn06U/lFGWyq7rcQ8hNzmuH7JQtQs21OzgRglD EklA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=QQBF037ir2neveiNV9S6vlyKu6iA0W4yp3JG1tCgnsw=; b=XIWifmVFVrPknG7g6cfmsY0T738EdhEFr95Bf/987cWmLflmgUGV/bbT9WN71jFfaL dqCzCwIdnnxCttRqvywVarjw0w7gAWBv75Kai2LS3gsuxW4qLAAMxsP6tJJkdzl+IekM tGeq8gVhwoR3HZKlzN5o3tIuh8KePRHLsj0bBq3kcYZiw1TxjpI/ru7/D2Qv3tJPBhOd PcvM7pTu5EEzna4OsunNPs4/3lQ+JdPxHUEqcqU3Iz109sNsXZE0lL00H9Tu3z8O0DW/ nc+j9yYjRkLzIbj71BzzRzBOmjPGWbNMsdR39TQAjMRn3uiui2p3JYn8EEkfO5WcgWuP /74w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=nqaE219F; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id o26-20020a635d5a000000b004703815aa10si847376pgm.721.2022.11.17.04.27.05; Thu, 17 Nov 2022 04:27:18 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=nqaE219F; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240038AbiKQMMX (ORCPT + 99 others); Thu, 17 Nov 2022 07:12:23 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41656 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240057AbiKQMMR (ORCPT ); Thu, 17 Nov 2022 07:12:17 -0500 Received: from mail-lf1-x136.google.com (mail-lf1-x136.google.com [IPv6:2a00:1450:4864:20::136]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B84FF70A25; Thu, 17 Nov 2022 04:12:08 -0800 (PST) Received: by mail-lf1-x136.google.com with SMTP id c1so2462225lfi.7; Thu, 17 Nov 2022 04:12:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=QQBF037ir2neveiNV9S6vlyKu6iA0W4yp3JG1tCgnsw=; b=nqaE219F+qHantJ2wcuOZFpENWvGmMilEgyGcDx7+OT+HAA1VrtIQuvvPCxdENNXSg V6iZ9bMLJETYKbrcGDMdcaKN4XDaRbqnXK2HaqMkH5Q3HjO3LykFSpWdIqmn5UBz+zjg IYjt7kLYj0uzoFrnPzHfdIEIrJyfgF2muqtvIfm5OE7oJ02lRkRIuf84Mck1k5AdGfcP eIB8XU9JR5qf8WqU2wePk4Iii6kRZibVOc+127OSZwjcQp6SRF+Wg9o9qB+EGQ7LdPYa 6P7d9U8pMD2MUlLLSXRQkYK1KlP9jFZChY7ufykp5SIMNBs+XC09d0kRYMYcKljT4d9O 9dTg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=QQBF037ir2neveiNV9S6vlyKu6iA0W4yp3JG1tCgnsw=; b=tCBsFYK6p8bujaDeDjUFsTYGArNfxOUDUKw/Pr1MDyhefWgxHoYJUcsK+zDeIuB1tV l1msD8Bx1iH2SI8ibZFmyDQnqpMdneFR+NIqhaNHpqShOA1c+AdGr4SkG2rZonTKGzrN 9vXOZKmhuQ6dA9ZqyGEWTIuabMWRmlg/ak2PtgzrDurIRKWe8eV/9cQ0fvR/VGWW2w6i u3JEm/6SdMLL25DrJnvGNMuX6Fj032fHnkivr2WhF+LxhCSleikMdfRMP27ldeImHXBb Vlgx3AIeuowoplLcdn3mV0jWgxdHJ4CRxDHIrmUOSzFoiPTglMXOUqYLC/u28DRxAfRi BTCg== X-Gm-Message-State: ANoB5pkY+7txYX24C+2iklSnDR/MMdM772pI6TTVhR7q2D58Y+8HM59K eTRkHOw7QeXkt2yrQHPikfk= X-Received: by 2002:a05:6512:2a8c:b0:4ac:102e:5ca5 with SMTP id dt12-20020a0565122a8c00b004ac102e5ca5mr895163lfb.236.1668687127135; Thu, 17 Nov 2022 04:12:07 -0800 (PST) Received: from localhost.localdomain (82-209-154-112.cust.bredband2.com. [82.209.154.112]) by smtp.gmail.com with ESMTPSA id a4-20020a056512200400b004a01105eea2sm120808lfb.150.2022.11.17.04.12.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Nov 2022 04:12:06 -0800 (PST) From: Marcus Folkesson To: Jiri Kosina , Jonathan Cameron , Srinivas Pandruvada , Benjamin Tissoires Cc: linux-input@vger.kernel.org, linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org, Marcus Folkesson , Jonathan Cameron Subject: [PATCH v2] HID: hid-sensor-custom: set fixed size for custom attributes Date: Thu, 17 Nov 2022 13:13:26 +0100 Message-Id: <20221117121326.5621-1-marcus.folkesson@gmail.com> X-Mailer: git-send-email 2.38.1 MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1749746229529119095?= X-GMAIL-MSGID: =?utf-8?q?1749746229529119095?= This is no bugfix (so no Fixes: tag is necessary) as it is taken care of in hid_sensor_custom_add_attributes(). The motivation for this patch is that: hid_sensor_custom_field.attr_name and hid_sensor_custom_field.attrs has the size of HID_CUSTOM_TOTAL_ATTRS and used in same context. We compare against HID_CUSTOM_TOTAL_ATTRS when looping through hid_custom_attrs. We will silent the smatch error: hid_sensor_custom_add_attributes() error: buffer overflow 'hid_custom_attrs' 8 <= 10 Signed-off-by: Marcus Folkesson Acked-by: Jonathan Cameron --- drivers/hid/hid-sensor-custom.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/hid/hid-sensor-custom.c b/drivers/hid/hid-sensor-custom.c index 32c2306e240d..602465ad2745 100644 --- a/drivers/hid/hid-sensor-custom.c +++ b/drivers/hid/hid-sensor-custom.c @@ -62,7 +62,7 @@ struct hid_sensor_sample { u32 raw_len; } __packed; -static struct attribute hid_custom_attrs[] = { +static struct attribute hid_custom_attrs[HID_CUSTOM_TOTAL_ATTRS] = { {.name = "name", .mode = S_IRUGO}, {.name = "units", .mode = S_IRUGO}, {.name = "unit-expo", .mode = S_IRUGO},