All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH AUTOSEL 5.15 01/16] auxdisplay: charlcd: checking for pointer reference before dereferencing
@ 2022-01-03 17:28 Sasha Levin
  2022-01-03 17:28   ` Sasha Levin
                   ` (14 more replies)
  0 siblings, 15 replies; 32+ messages in thread
From: Sasha Levin @ 2022-01-03 17:28 UTC (permalink / raw)
  To: linux-kernel, stable; +Cc: Luiz Sampaio, Miguel Ojeda, Sasha Levin

From: Luiz Sampaio <sampaio.ime@gmail.com>

[ 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>
---
 drivers/auxdisplay/charlcd.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/auxdisplay/charlcd.c b/drivers/auxdisplay/charlcd.c
index 304accde365c8..6c010d4efa4ae 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;
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 32+ messages in thread

end of thread, other threads:[~2022-01-03 17:32 UTC | newest]

Thread overview: 32+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-03 17:28 [PATCH AUTOSEL 5.15 01/16] auxdisplay: charlcd: checking for pointer reference before dereferencing Sasha Levin
2022-01-03 17:28 ` [PATCH AUTOSEL 5.15 02/16] drm/amdgpu: fix dropped backing store handling in amdgpu_dma_buf_move_notify Sasha Levin
2022-01-03 17:28   ` Sasha Levin
2022-01-03 17:28   ` Sasha Levin
2022-01-03 17:28 ` [PATCH AUTOSEL 5.15 03/16] drm/amd/pm: Fix xgmi link control on aldebaran Sasha Levin
2022-01-03 17:28   ` Sasha Levin
2022-01-03 17:28   ` Sasha Levin
2022-01-03 17:28 ` [PATCH AUTOSEL 5.15 04/16] usb: mtu3: fix interval value for intr and isoc Sasha Levin
2022-01-03 17:28   ` Sasha Levin
2022-01-03 17:28   ` Sasha Levin
2022-01-03 17:28 ` [PATCH AUTOSEL 5.15 05/16] scsi: libiscsi: Fix UAF in iscsi_conn_get_param()/iscsi_conn_teardown() Sasha Levin
2022-01-03 17:28 ` [PATCH AUTOSEL 5.15 06/16] ip6_vti: initialize __ip6_tnl_parm struct in vti6_siocdevprivate Sasha Levin
2022-01-03 17:28 ` [PATCH AUTOSEL 5.15 07/16] net: udp: fix alignment problem in udp4_seq_show() Sasha Levin
2022-01-03 17:28 ` [PATCH AUTOSEL 5.15 08/16] atlantic: Fix buff_ring OOB in aq_ring_rx_clean Sasha Levin
2022-01-03 17:28 ` [PATCH AUTOSEL 5.15 09/16] drm/amd/pm: skip setting gfx cgpg in the s0ix suspend-resume Sasha Levin
2022-01-03 17:28   ` Sasha Levin
2022-01-03 17:28   ` Sasha Levin
2022-01-03 17:28 ` [PATCH AUTOSEL 5.15 10/16] drm/amdgpu: always reset the asic in suspend (v2) Sasha Levin
2022-01-03 17:28   ` Sasha Levin
2022-01-03 17:28   ` Sasha Levin
2022-01-03 17:28 ` [PATCH AUTOSEL 5.15 11/16] drm/amdgpu: put SMU into proper state on runpm suspending for BOCO capable platform Sasha Levin
2022-01-03 17:28   ` Sasha Levin
2022-01-03 17:28   ` Sasha Levin
2022-01-03 17:28 ` [PATCH AUTOSEL 5.15 12/16] mISDN: change function names to avoid conflicts Sasha Levin
2022-01-03 17:28 ` [PATCH AUTOSEL 5.15 13/16] drm/amd/display: fix B0 TMDS deepcolor no dislay issue Sasha Levin
2022-01-03 17:28   ` Sasha Levin
2022-01-03 17:28   ` Sasha Levin
2022-01-03 17:28 ` [PATCH AUTOSEL 5.15 14/16] drm/amd/display: Added power down for DCN10 Sasha Levin
2022-01-03 17:28   ` Sasha Levin
2022-01-03 17:28   ` Sasha Levin
2022-01-03 17:28 ` [PATCH AUTOSEL 5.15 15/16] ipv6: raw: check passed optlen before reading Sasha Levin
2022-01-03 17:28 ` [PATCH AUTOSEL 5.15 16/16] userfaultfd/selftests: fix hugetlb area allocations Sasha Levin

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.