Skip to content

Commit 4daa9ff

Browse files
sampaio23ojeda
authored andcommitted
auxdisplay: charlcd: checking for pointer reference before dereferencing
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 <[email protected]> Signed-off-by: Miguel Ojeda <[email protected]>
1 parent 94047df commit 4daa9ff

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

drivers/auxdisplay/charlcd.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -578,6 +578,9 @@ static int charlcd_init(struct charlcd *lcd)
578578
* Since charlcd_init_display() needs to write data, we have to
579579
* enable mark the LCD initialized just before.
580580
*/
581+
if (WARN_ON(!lcd->ops->init_display))
582+
return -EINVAL;
583+
581584
ret = lcd->ops->init_display(lcd);
582585
if (ret)
583586
return ret;

0 commit comments

Comments
 (0)