public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Dmitry Torokhov <dmitry.torokhov@gmail.com>
To: Johan Hovold <johan@kernel.org>
Cc: linux-input@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2] Input: usbtouchscreen - add driver_info sanity check
Date: Thu, 23 Jun 2022 08:59:52 -0700	[thread overview]
Message-ID: <YrSN+DYQun/IOPh7@google.com> (raw)
In-Reply-To: <20220623062446.16944-1-johan@kernel.org>

On Thu, Jun 23, 2022 at 08:24:46AM +0200, Johan Hovold wrote:
> Add a sanity check on the device id-table driver_info field to make sure
> we never access a type structure (and function pointers) outside of the
> device info array (e.g. if someone fails to ifdef a device-id entry).
> 
> Note that this also suppresses a compiler warning with -Warray-bounds
> (gcc-11.3.0) when compile-testing the driver without enabling any of
> the device type Kconfig options:
> 
>     drivers/input/touchscreen/usbtouchscreen.c: In function 'usbtouch_probe':
>     drivers/input/touchscreen/usbtouchscreen.c:1668:16:warning: array subscript <unknown> is outside array bounds of 'struct usbtouch_device_info[0]' [-Warray-bounds]
>      1668 |         type = &usbtouch_dev_info[id->driver_info];
> 
> Signed-off-by: Johan Hovold <johan@kernel.org>
> ---
> 
> Changes in v2
>  - use ARRAY_SIZE() for the sanity check (Dmitry)
>  - drop the dummy entry and combine the two patches as the sanity check
>    itself is enough to suppress the compiler warning (Dmitry)
>  - use -ENODEV instead of -EINVAL even if this means no error will be
>    logged in the unlikely event of a future driver bug

Is this on purpose or because I happened to have used this error code
when I suggested the change? I'm fine with returning -EINVAL there.

Thanks.

-- 
Dmitry

  reply	other threads:[~2022-06-23 15:59 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-23  6:24 [PATCH v2] Input: usbtouchscreen - add driver_info sanity check Johan Hovold
2022-06-23 15:59 ` Dmitry Torokhov [this message]
2022-06-27  7:46   ` Johan Hovold
2022-06-27 22:13     ` Dmitry Torokhov

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=YrSN+DYQun/IOPh7@google.com \
    --to=dmitry.torokhov@gmail.com \
    --cc=johan@kernel.org \
    --cc=linux-input@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    /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