Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp1717581rwb; Sun, 2 Oct 2022 06:41:38 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5gu4VxniOEki5KA+IG/Ohb5d6Ugx1a+HxSS7EnrgEFFDyHU6xwzek8e5lmm6rgp6NN9M2i X-Received: by 2002:a17:907:72d2:b0:782:6c4c:e979 with SMTP id du18-20020a17090772d200b007826c4ce979mr12126312ejc.369.1664718098477; Sun, 02 Oct 2022 06:41:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1664718098; cv=none; d=google.com; s=arc-20160816; b=FQjk5UfCutkzofGaV4RtmYkKs3xov6gGV7AFvXHKPSqzBDXph+DWt9rNlmqkCKHs4s CiL3f04+n/OwEHyInykJx85kVN9wwBffp8pbzrqHxLesiCIhtUtlkzvLaRK4JKkUK+BZ zYigY70UR/zMj/flmuKgjGVoYKtTwCWhFif75bHFqDsgxGPZNYnWKO5bqhF1JjHIbJWp GHj58fZURz8qTWL35KSYpxVuTM/pJO9+YvODb+se1BsE1RxmIEci4YlZomeu6esB4FDY vI4XDLheTCZ4+b4aXHU0NyCVfZH5zYtMZOpbr1kci2+qZLvxDscYoaw5Jm63u00V9bw+ CTEg== 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 :references:in-reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=O4t4N0GTYe08ea5sSUmbbqIrf+8NDy9qUHx9DlyeWqo=; b=JpClEHtN/1dxjNhYpmEWaiwgYAsHqy2Ekqgp8fhY7ThMYNykjlPpuVZXaE7zFphxx4 e1ixxg/syS9DSiYm/0KLQ4U9h6mKCOwwYCde0D0kqh5EQ44NiuAHmr/gYlUPkURnMPiD oq+eeTYI7EF4MzO6zlyqdRQ3ihH0Z9JhMAGOmSqHfrMrWPUd14j7l/1EYpZCSTiAzSEA CMq73I8CNjGnMSEHNbUMV7ZxwtOEZYZF4eOy5gYXJ03GmgbslSi3yUvZkNa79gABmWFx i1yiW2WXxbUX3WsdK9HEmVp7Kl3YX9rly4iYQYJknx/p8vzu3v9ZyESRrjnv6Vw/mvjF NaGQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=OLs61fMB; 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=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id cr11-20020a170906d54b00b0072ed60fb78asi5723875ejc.548.2022.10.02.06.41.08; Sun, 02 Oct 2022 06:41:38 -0700 (PDT) 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=@kernel.org header.s=k20201202 header.b=OLs61fMB; 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=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229763AbiJBNah (ORCPT + 99 others); Sun, 2 Oct 2022 09:30:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51252 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229449AbiJBNae (ORCPT ); Sun, 2 Oct 2022 09:30:34 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 285E217E0F; Sun, 2 Oct 2022 06:30:33 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id B2A4D60EC4; Sun, 2 Oct 2022 13:30:32 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C53DDC433C1; Sun, 2 Oct 2022 13:30:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1664717432; bh=us5hueHqD/j3wWOvKZqHtPA6xEsfRnpIDe6d2mNdKwQ=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=OLs61fMBccvbuP12w2NwCeAWBlnxcV+LC94oS/rM9wA/jDJ33FQ22oXjaiAswgqc9 rpD1i+/EYWBio1XsRnFSxrNNmSjv92qz2fk3gAC42TolBo75W4cpvH4Cve7XUfjp/c dJ67PRHXNGn6/rc6EGv9oWS8RGnNzL8CmyP7vhSvEpVNBs14Yfz7cAKRly76S6U0Ox Bn1wxOBHodc30YJ6l+Ku+59j/EDfelOuo/k3ssDXST64qFNJVRoeauY+l3/Mq/lPy/ 05FGXIvuHGC+hwDzWuW1QyJrRp9Gq5RRzxtRHGOs0SKktfQJr65R9rfW3uBys7A6Yi 3/0EvQ4DJdS5A== Date: Sun, 2 Oct 2022 14:30:47 +0100 From: Jonathan Cameron To: Marcus Folkesson Cc: Jiri Kosina , Srinivas Pandruvada , Benjamin Tissoires , linux-input@vger.kernel.org, linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] HID: hid-sensor-custom: set fixed size for custom attributes Message-ID: <20221002143047.7ab1dda5@jic23-huawei> In-Reply-To: <20220928075913.64125-1-marcus.folkesson@gmail.com> References: <20220928075913.64125-1-marcus.folkesson@gmail.com> X-Mailer: Claws Mail 4.1.0 (GTK 3.24.34; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, 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 On Wed, 28 Sep 2022 09:59:13 +0200 Marcus Folkesson wrote: > 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 Slightly ugly fix, but I guess it's the easiest solution. 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},