Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] drm/msm/mdp4: mdp4_kms->dev dereferenced before NULL check in
  mdp4_destroy()
--

commit 26c33f96a5c574b9e64b260a7b6a74a4cfcc0b65
Author: Yaohan Li <[email protected]>

drm/msm: release the cursor flip work before the KMS is torn down

This commit releases the DRM-managed cursor flip work cleanup action from
mdp4_destroy() and mdp5_kms_destroy() before the KMS VM is destroyed.

> diff --git a/drivers/gpu/drm/msm/disp/mdp4/mdp4_kms.c 
> b/drivers/gpu/drm/msm/disp/mdp4/mdp4_kms.c
> index ab7b62381685f..3fd528eeff0e3 100644
> --- a/drivers/gpu/drm/msm/disp/mdp4/mdp4_kms.c
> +++ b/drivers/gpu/drm/msm/disp/mdp4/mdp4_kms.c
> @@ -136,6 +136,19 @@ static void mdp4_destroy(struct msm_kms *kms)
>  {
>       struct mdp4_kms *mdp4_kms = to_mdp4_kms(to_mdp_kms(kms));
>       struct device *dev = mdp4_kms->dev->dev;
> +     struct drm_crtc *crtc;
> +
> +     /*
> +      * Release the cursor flip work while the VM is still alive.  The
> +      * cleanup is registered as a DRM-managed action, so it would only run
> +      * at the final drm_dev_put(), long after drm_gpuvm_put() below has
> +      * destroyed the VM that unref_cursor_worker() needs.  The interrupts
> +      * and the KMS workqueue have been stopped at this point, so no new
> +      * cursor update can be queued any more.
> +      */
> +     if (mdp4_kms->dev)
> +             drm_for_each_crtc(crtc, mdp4_kms->dev)
> +                     mdp4_crtc_release_flip_work(crtc);

[Severity: Medium]
Can the new NULL check on mdp4_kms->dev ever protect against a NULL
mdp4_kms->dev when mdp4_kms->dev->dev is dereferenced right at the top of
mdp4_destroy()?

In mdp4_kms_init(), mdp_kms_init() -> msm_kms_init() sets kms->funcs before
mdp4_kms->dev is assigned, so if msm_kms_init() fails afterwards,
msm_drm_kms_uninit() calls mdp4_destroy() with mdp4_kms->dev == NULL and
triggers a NULL pointer dereference before reaching the new guard (while
dev is only used later under if (mdp4_kms->rpm_enabled)).

-- 
Sashiko AI review ยท 
https://sashiko.dev/#/patchset/[email protected]?part=1

Reply via email to