lkml.org 
[lkml]   [2022]   [Jun]   [23]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH v2] Input: usbtouchscreen - add driver_info sanity check
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

\
 
 \ /
  Last update: 2022-06-23 18:02    [W:0.699 / U:0.104 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site