linux-input.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jonathan Cameron <jic23@kernel.org>
To: Marcus Folkesson <marcus.folkesson@gmail.com>
Cc: Jiri Kosina <jikos@kernel.org>,
	Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>,
	Benjamin Tissoires <benjamin.tissoires@redhat.com>,
	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
Date: Sun, 2 Oct 2022 14:30:47 +0100	[thread overview]
Message-ID: <20221002143047.7ab1dda5@jic23-huawei> (raw)
In-Reply-To: <20220928075913.64125-1-marcus.folkesson@gmail.com>

On Wed, 28 Sep 2022 09:59:13 +0200
Marcus Folkesson <marcus.folkesson@gmail.com> 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 <marcus.folkesson@gmail.com>
Slightly ugly fix, but I guess it's the easiest solution.

Acked-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>

> ---
>  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},


      reply	other threads:[~2022-10-02 13:30 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-28  7:59 [PATCH] HID: hid-sensor-custom: set fixed size for custom attributes Marcus Folkesson
2022-10-02 13:30 ` Jonathan Cameron [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20221002143047.7ab1dda5@jic23-huawei \
    --to=jic23@kernel.org \
    --cc=benjamin.tissoires@redhat.com \
    --cc=jikos@kernel.org \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-input@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=marcus.folkesson@gmail.com \
    --cc=srinivas.pandruvada@linux.intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).