dri-devel Archive on 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 v3 3/8] drm/msm: unwind msm_drm_kms_init() on failure
Date: Sat, 12 Sep 2026 13:33:11 +0000	[thread overview]
Message-ID: <20260912133311.D63651F00893@smtp.kernel.org> (raw)
In-Reply-To: <20260912-fd-kms-fix-smmu-v3-3-a7ddc6fe2032@oss.qualcomm.com>

Thank you for your contribution! Sashiko AI review found 3 potential issue(s) to consider:

Pre-existing issues:
- [High] msm_disp_snapshot_destroy() unconditionally passes an ERR_PTR to kthread_destroy_worker() if kthread creation failed.
- [High] destroy_workqueue() is called on a potentially NULL kms->wq when msm_kms_init() fails.
- [High] Double destruction of DRM private object state if hw_init fails.
--

commit 972acdabb4a5813d8316cd0796e9b9df36ce8dff
Author: Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com>
Subject: drm/msm: unwind msm_drm_kms_init() on failure

This commit updates the error unwinding in msm_drm_kms_init() and
msm_drm_init() to avoid calling the full teardown process when early
initialization steps fail. It undoes only the steps which have successfully
completed.

> diff --git a/drivers/gpu/drm/msm/msm_kms.c b/drivers/gpu/drm/msm/msm_kms.c
> --- a/drivers/gpu/drm/msm/msm_kms.c
> +++ b/drivers/gpu/drm/msm/msm_kms.c
[ ... ]
> @@ -328,14 +334,20 @@ int msm_drm_kms_init(struct device *dev, const struct drm_driver *drv)
>  	pm_runtime_put_sync(dev);
>  	if (ret < 0) {
>  		DRM_DEV_ERROR(dev, "failed to install IRQ handler\n");
> -		goto err_msm_uninit;
> +		goto err_destroy_event_threads;
>  	}
>  
>  	drm_mode_config_reset(ddev);
>  
>  	return 0;
>  
> -err_msm_uninit:
> +err_destroy_event_threads:
> +	msm_drm_kms_destroy_event_threads(kms);
> +err_destroy_kms:
> +	msm_disp_snapshot_destroy(ddev);

[Severity: High]
This is a pre-existing issue, but does this error path lead to a kernel 
panic? 

If kthread_run_worker fails in msm_disp_snapshot_init, it stores an ERR_PTR 
in kms->dump_worker but returns success. When we hit this error path and call 
msm_disp_snapshot_destroy, it evaluates if (kms->dump_worker) which is true 
for an ERR_PTR, and passes the error pointer directly to 
kthread_destroy_worker, leading to an invalid memory dereference.

> +	if (kms->funcs)
> +		kms->funcs->destroy(kms);

[Severity: High]
This is also a pre-existing issue, but could this cause a NULL pointer 
dereference if the workqueue failed to allocate?

If alloc_ordered_workqueue fails earlier in msm_kms_init, kms->wq is NULL 
but kms->funcs is already assigned. This error propagates up, jumping to 
err_destroy_kms, and we call kms->funcs->destroy here. That delegates to 
msm_kms_destroy, which unconditionally calls destroy_workqueue(kms->wq) 
without checking if the workqueue was actually allocated.

[Severity: High]
Additionally, this is a pre-existing issue, but can this lead to a double 
free and list corruption in the DPU driver?

If dpu_kms_hw_init fails, it internally cleans up by calling 
_dpu_kms_hw_destroy. This invokes drm_atomic_private_obj_fini to remove 
the private object from its list via list_del. The error propagates to 
msm_drm_kms_init, we jump to err_destroy_kms, and execute this destroy 
callback. This resolves to dpu_kms_destroy, which calls 
_dpu_kms_hw_destroy a second time and executes list_del on a poisoned 
list head.

> +
>  	return ret;
>  }

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260912-fd-kms-fix-smmu-v3-0-a7ddc6fe2032@oss.qualcomm.com?part=3

  reply	other threads:[~2026-09-12 13:33 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-12 12:48 [PATCH v3 0/8] drm/msm: fix SMMU fault dumps Dmitry Baryshkov
2026-09-12 12:48 ` [PATCH v3 1/8] drm/msm: serialise framebuffer pin state Dmitry Baryshkov
2026-09-12 12:48 ` [PATCH v3 2/8] drm/msm: fix framebuffer pin refcount leak on prepare failure Dmitry Baryshkov
2026-09-12 12:48 ` [PATCH v3 3/8] drm/msm: unwind msm_drm_kms_init() on failure Dmitry Baryshkov
2026-09-12 13:33   ` sashiko-bot [this message]
2026-09-12 12:48 ` [PATCH v3 4/8] drm/msm: release scanout framebuffers only after a vblank Dmitry Baryshkov
2026-09-12 12:59   ` sashiko-bot
2026-09-12 12:48 ` [PATCH v3 5/8] drm/msm/dpu: clear the DSPP pointer when no DSPP is assigned Dmitry Baryshkov
2026-09-12 13:02   ` sashiko-bot
2026-09-12 12:48 ` [PATCH v3 6/8] drm/msm/dpu: clear the DSC blocks left by a previous reservation Dmitry Baryshkov
2026-09-12 12:59   ` sashiko-bot
2026-09-12 12:48 ` [PATCH v3 7/8] drm/msm/dpu: only reassign resources when the encoder is reprogrammed Dmitry Baryshkov
2026-09-12 12:48 ` [PATCH v3 8/8] drm/ci: mark pixel-format tests as passing on SC7180 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=20260912133311.D63651F00893@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox