All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Dmitry Baryshkov" <dmitry.baryshkov@oss.qualcomm.com>
Cc: dri-devel@lists.freedesktop.org
Subject: Re: [PATCH 09/11] drm/msm/dpu: unwind a failed dpu_kms_hw_init() step by step
Date: Sat, 03 Oct 2026 01:34:30 +0000	[thread overview]
Message-ID: <20261003013431.504BF1F00893@smtp.kernel.org> (raw)
In-Reply-To: <20261003-msm-kms-destroy-fixes-v1-9-e062b7dae77f@oss.qualcomm.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] drm/msm/dpu: use-after-free on hw_vbif during bind retry
--

commit 010fe925950b01a30ca06eec05c2a4db435b69ed
Author: Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com>

drm/msm/dpu: unwind a failed dpu_kms_hw_init() step by step

This commit replaces the blanket _dpu_kms_hw_destroy() call in the error
path of dpu_kms_hw_init() with step-by-step unwinding. Only the completed
steps are undone, in reverse order.

> diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c b/drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c
> index 65ba8fa697e94..2de4d881d13d9 100644
> --- a/drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c
> +++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c
[ ... ]
> @@ -1263,7 +1263,7 @@ static int dpu_kms_hw_init(struct dpu_kms *dpu_kms)
>  	rc = _dpu_kms_drm_obj_init(dpu_kms);
>  	if (rc) {
>  		DPU_ERROR("modeset init failed: %d\n", rc);
> -		goto err_pm_put;
> +		goto err_mmu_destroy;
>  	}
>  
>  	dpu_vbif_init_memtypes(dpu_kms);
> @@ -1272,10 +1272,12 @@ static int dpu_kms_hw_init(struct dpu_kms *dpu_kms)
>  
>  	return 0;
>  
> +err_mmu_destroy:
> +	_dpu_kms_mmu_destroy(dpu_kms);

[Severity: High]
If initialization fails after dpu_kms->hw_vbif is allocated, such as when
_dpu_kms_drm_obj_init() fails, the error path jumps to err_mmu_destroy. Can
this regression leave a dangling pointer in dpu_kms->hw_vbif?

Since the memory for dpu_kms->hw_vbif is allocated via drmm, it will be freed
when the component bind fails and the DRM device is torn down. However,
dpu_kms itself persists because it is allocated via devm.

Could a subsequent bind retry trigger a use-after-free?

When a deferred probe or bind retry occurs, dpu_kms_hw_init() calls
pm_runtime_resume_and_get(), which triggers the runtime PM resume callback
and accesses the dangling pointer:

dpu_runtime_resume()
  dpu_vbif_init_memtypes()
    vbif = dpu_kms->hw_vbif;
    if (vbif && vbif->cap && ...) 

This would result in a use-after-free on the previously freed vbif memory.

Is it necessary to explicitly clear dpu_kms->hw_vbif in the unwind path to
prevent it from being accessed during bind retries?

>  err_pm_put:
>  	pm_runtime_put_sync(&dpu_kms->pdev->dev);
> -error:
> -	_dpu_kms_hw_destroy(dpu_kms);
> +err_global_obj_fini:
> +	dpu_kms_global_obj_fini(dpu_kms);
>  
>  	return rc;
>  }

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261003-msm-kms-destroy-fixes-v1-0-e062b7dae77f@oss.qualcomm.com?part=9

  reply	other threads:[~2026-10-03  1:34 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-03  0:27 [PATCH 00/11] drm/msm: fix the error handling of the KMS init Dmitry Baryshkov
2026-10-03  0:27 ` [PATCH 01/11] drm/msm: fail the snapshot init when its worker cannot be created Dmitry Baryshkov
2026-10-03  0:27 ` [PATCH 02/11] drm/msm: unwind msm_drm_kms_init() on failure Dmitry Baryshkov
2026-10-03  0:27 ` [PATCH 03/11] drm/msm: clean up after a failed msm_kms_init() Dmitry Baryshkov
2026-10-03  0:27 ` [PATCH 04/11] drm/msm: let the kms drivers clean up a failed kms_init() Dmitry Baryshkov
2026-10-03  1:34   ` sashiko-bot
2026-10-03  0:27 ` [PATCH 05/11] drm/msm/mdp5: unwind a failed mdp5_kms_init() Dmitry Baryshkov
2026-10-03  0:27 ` [PATCH 06/11] drm/msm/mdp4: unwind a failed mdp4_kms_init() Dmitry Baryshkov
2026-10-03  0:27 ` [PATCH 07/11] drm/msm/dpu: don't tear down a failed hw_init twice Dmitry Baryshkov
2026-10-03  0:27 ` [PATCH 08/11] drm/msm: tear down only a successfully initialised KMS Dmitry Baryshkov
2026-10-03  0:27 ` [PATCH 09/11] drm/msm/dpu: unwind a failed dpu_kms_hw_init() step by step Dmitry Baryshkov
2026-10-03  1:34   ` sashiko-bot [this message]
2026-10-03  0:27 ` [PATCH 10/11] drm/msm/mdp4: disable the vdd regulator on teardown Dmitry Baryshkov
2026-10-03  0:27 ` [PATCH 11/11] drm/msm: drop the runtime PM flags from the KMS teardown Dmitry Baryshkov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261003013431.504BF1F00893@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=dmitry.baryshkov@oss.qualcomm.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=sashiko-reviews@lists.linux.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.