summaryrefslogtreecommitdiff
path: root/drivers/auxdisplay
diff options
context:
space:
mode:
authorLuiz Sampaio <sampaio.ime@gmail.com>2021-11-10 01:07:32 +0300
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2022-01-11 17:35:17 +0300
commit4ed66cdc542fdb948d67f2254fdac4106786a76e (patch)
treee8ec086e6cbcf51c8bf4f3ca2108a07b937d7a7a /drivers/auxdisplay
parent8a7520c49994ab1d43221e6445252e9fad0b3391 (diff)
downloadlinux-4ed66cdc542fdb948d67f2254fdac4106786a76e.tar.xz
auxdisplay: charlcd: checking for pointer reference before dereferencing
[ Upstream commit 4daa9ff89ef27be43c15995412d6aee393a78200 ] 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. Signed-off-by: Luiz Sampaio <sampaio.ime@gmail.com> Signed-off-by: Miguel Ojeda <ojeda@kernel.org> Signed-off-by: Sasha Levin <sashal@kernel.org>
Diffstat (limited to 'drivers/auxdisplay')
-rw-r--r--drivers/auxdisplay/charlcd.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/drivers/auxdisplay/charlcd.c b/drivers/auxdisplay/charlcd.c
index 304accde365c..6c010d4efa4a 100644
--- a/drivers/auxdisplay/charlcd.c
+++ b/drivers/auxdisplay/charlcd.c
@@ -578,6 +578,9 @@ static int charlcd_init(struct charlcd *lcd)
* Since charlcd_init_display() needs to write data, we have to
* enable mark the LCD initialized just before.
*/
+ if (WARN_ON(!lcd->ops->init_display))
+ return -EINVAL;
+
ret = lcd->ops->init_display(lcd);
if (ret)
return ret;