All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Rob Clark" <robin.clark@oss.qualcomm.com>
Cc: dri-devel@lists.freedesktop.org
Subject: Re: [PATCH v2 3/3] drm/msm: Validate lazy VM in GEM_NEW
Date: Thu, 25 Jun 2026 19:23:02 +0000	[thread overview]
Message-ID: <20260625192303.225381F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260625191537.47965-4-robin.clark@oss.qualcomm.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] The newly allocated GEM object 'obj' is leaked on the error path if the VM is not found or unsupported.
--

commit ebb450a0150beb70fa2ad61c737f157a48b8cb86
Author: Rob Clark <robin.clark@oss.qualcomm.com>

drm/msm: Validate lazy VM in GEM_NEW

Otherwise creating a _NO_SHARE BO before any BOs are mapped could cause
a NPE.

> diff --git a/drivers/gpu/drm/msm/msm_gem.c b/drivers/gpu/drm/msm/msm_gem.c
> index efd3d3c9a4490..733a094354e1d 100644
> --- a/drivers/gpu/drm/msm/msm_gem.c
> +++ b/drivers/gpu/drm/msm/msm_gem.c
> @@ -1147,7 +1147,12 @@ int msm_gem_new_handle(struct drm_device *dev, struct drm_file *file,
>  
>  	if (flags & MSM_BO_NO_SHARE) {
>  		struct msm_context *ctx = file->driver_priv;
> -		struct drm_gem_object *r_obj = drm_gpuvm_resv_obj(ctx->vm);
> +		struct drm_gpuvm *vm = msm_context_vm(dev, ctx);
> +
> +		if (!vm)
> +			return UERR(EINVAL, dev, "not supported with shared VM");
                        ^^^^

[Severity: High]
Does this code leak the newly allocated obj?

Looking earlier in msm_gem_new_handle(), obj is allocated:

	obj = msm_gem_new(dev, size, flags);

	if (IS_ERR(obj))
		return PTR_ERR(obj);

If vm is NULL, we return directly here without calling drm_gem_object_put(obj)
to release the reference.

> +
> +		struct drm_gem_object *r_obj = drm_gpuvm_resv_obj(vm);
>  
>  		drm_gem_object_get(r_obj);
>

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260625191537.47965-1-robin.clark@oss.qualcomm.com?part=3

      reply	other threads:[~2026-06-25 19:23 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-25 19:15 [PATCH v2 0/3] drm/msm: A couple lazy-vm fixes Rob Clark
2026-06-25 19:15 ` [PATCH v2 1/3] drm/msm: Fix barriers accessing ctx vm Rob Clark
2026-06-25 19:28   ` sashiko-bot
2026-06-25 19:15 ` [PATCH v2 2/3] drm/msm: Validate lazy VM is created in GEM_SUBMIT Rob Clark
2026-06-25 19:32   ` sashiko-bot
2026-06-25 19:15 ` [PATCH v2 3/3] drm/msm: Validate lazy VM in GEM_NEW Rob Clark
2026-06-25 19:23   ` sashiko-bot [this message]

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=20260625192303.225381F000E9@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=robin.clark@oss.qualcomm.com \
    --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.