Skip to content

Commit

Permalink
drm/rockchip: psr: do not dereference encoder before it is null checked.
Browse files Browse the repository at this point in the history
'encoder' is dereferenced 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: 5182c1a ("drm/rockchip: add an common abstracted PSR driver")
Cc: stable@vger.kernel.org
Signed-off-by: Enric Balletbo i Serra <enric.balletbo@collabora.com>
Signed-off-by: Heiko Stuebner <heiko@sntech.de>
Link: https://patchwork.freedesktop.org/patch/msgid/20181013105654.11827-1-enric.balletbo@collabora.com
  • Loading branch information
Enric Balletbo i Serra authored and Heiko Stuebner committed Oct 16, 2018
1 parent 649fdce commit 4eda776
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion drivers/gpu/drm/rockchip/rockchip_drm_psr.c
Original file line number Diff line number Diff line change
Expand Up @@ -189,12 +189,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;
Expand Down

0 comments on commit 4eda776

Please sign in to comment.