mirror of
git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2025-08-05 16:54:27 +00:00
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 <sampaio.ime@gmail.com> Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
This commit is contained in:
parent
94047df12f
commit
4daa9ff89e
1 changed files with 3 additions and 0 deletions
|
@ -578,6 +578,9 @@ static int charlcd_init(struct charlcd *lcd)
|
||||||
* Since charlcd_init_display() needs to write data, we have to
|
* Since charlcd_init_display() needs to write data, we have to
|
||||||
* enable mark the LCD initialized just before.
|
* enable mark the LCD initialized just before.
|
||||||
*/
|
*/
|
||||||
|
if (WARN_ON(!lcd->ops->init_display))
|
||||||
|
return -EINVAL;
|
||||||
|
|
||||||
ret = lcd->ops->init_display(lcd);
|
ret = lcd->ops->init_display(lcd);
|
||||||
if (ret)
|
if (ret)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
Loading…
Add table
Reference in a new issue