[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CANiq72kgm-5CidoN8VRLnWokiDSWsQcMFbaUd4WKOnbPsON9RQ@mail.gmail.com>
Date: Mon, 8 Nov 2021 12:58:33 +0100
From: Miguel Ojeda <miguel.ojeda.sandonis@...il.com>
To: Luiz Sampaio <sampaio.ime@...il.com>
Cc: Miguel Ojeda <ojeda@...nel.org>,
linux-kernel <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH 2/2] auxdisplay: charlcd: checking for pointer reference
before dereferencing
On Sun, Nov 7, 2021 at 4:03 PM Luiz Sampaio <sampaio.ime@...il.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
Powered by blists - more mailing lists