linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] drm/rockchip: psr: do not dereference encoder before it is null checked.
@ 2018-10-13 10:56 Enric Balletbo i Serra
  2018-10-16 13:00 ` Heiko Stuebner
  0 siblings, 1 reply; 2+ messages in thread
From: Enric Balletbo i Serra @ 2018-10-13 10:56 UTC (permalink / raw)
  To: linux-arm-kernel

'encoder' is deferenced before it is null sanity checked, hence we
potentially have a null pointer dereference bug. Instead, initialise
drm_drv from encoder->dev->dev_private after we are sure 'encoder' is
not null.

Fixes: 5182c1a556d7f ("drm/rockchip: add an common abstracted PSR driver")
Signed-off-by: Enric Balletbo i Serra <enric.balletbo@collabora.com>
---

 drivers/gpu/drm/rockchip/rockchip_drm_psr.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_psr.c b/drivers/gpu/drm/rockchip/rockchip_drm_psr.c
index 1635485955d3..22a70ab6e214 100644
--- a/drivers/gpu/drm/rockchip/rockchip_drm_psr.c
+++ b/drivers/gpu/drm/rockchip/rockchip_drm_psr.c
@@ -226,12 +226,14 @@ EXPORT_SYMBOL(rockchip_drm_psr_flush_all);
 int rockchip_drm_psr_register(struct drm_encoder *encoder,
 			int (*psr_set)(struct drm_encoder *, bool enable))
 {
-	struct rockchip_drm_private *drm_drv = encoder->dev->dev_private;
+	struct rockchip_drm_private *drm_drv;
 	struct psr_drv *psr;
 
 	if (!encoder || !psr_set)
 		return -EINVAL;
 
+	drm_drv = encoder->dev->dev_private;
+
 	psr = kzalloc(sizeof(struct psr_drv), GFP_KERNEL);
 	if (!psr)
 		return -ENOMEM;
-- 
2.19.1

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

* [PATCH] drm/rockchip: psr: do not dereference encoder before it is null checked.
  2018-10-13 10:56 [PATCH] drm/rockchip: psr: do not dereference encoder before it is null checked Enric Balletbo i Serra
@ 2018-10-16 13:00 ` Heiko Stuebner
  0 siblings, 0 replies; 2+ messages in thread
From: Heiko Stuebner @ 2018-10-16 13:00 UTC (permalink / raw)
  To: linux-arm-kernel

Am Samstag, 13. Oktober 2018, 12:56:54 CEST schrieb Enric Balletbo i Serra:
> 'encoder' is deferenced before it is null sanity checked, hence we
> potentially have a null pointer dereference bug. Instead, initialise
> drm_drv from encoder->dev->dev_private after we are sure 'encoder' is
> not null.
> 
> Fixes: 5182c1a556d7f ("drm/rockchip: add an common abstracted PSR driver")
> Signed-off-by: Enric Balletbo i Serra <enric.balletbo@collabora.com>

added a stable-tag and applied to drm-misc-next

Thanks
Heiko

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

end of thread, other threads:[~2018-10-16 13:00 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-10-13 10:56 [PATCH] drm/rockchip: psr: do not dereference encoder before it is null checked Enric Balletbo i Serra
2018-10-16 13:00 ` Heiko Stuebner

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).