lkml.org 
[lkml]   [2021]   [Nov]   [8]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
Date
SubjectRe: [PATCH 2/2] auxdisplay: charlcd: checking for pointer reference before dereferencing
On Sun, Nov 7, 2021 at 4:03 PM Luiz Sampaio <sampaio.ime@gmail.com> wrote:
>
> Check if the pointer lcd->ops->init_display exists before dereferencing it.
> If a driver called charlcd_init() without defining the ops, this would
> return segmentation fault, as happened to me when implementing a charlcd
> driver. Checking the pointer before dereferencing protects from
> segmentation fault.

It can't hurt -- thanks! I think `EINVAL` makes more sense here, also
we could use `WARN_ON`:

if (WARN_ON(!lcd->ops->init_display))
return -EINVAL;

Cheers,
Miguel

\
 
 \ /
  Last update: 2021-11-08 13:01    [W:0.094 / U:0.316 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site