All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Dan Carpenter" <error27@gmail.com>
Cc: dri-devel@lists.freedesktop.org
Subject: Re: [PATCH] drm/vmwgfx: Fix NULL vs error pointer bug in vmw_prime_import_sg_table()
Date: Mon, 29 Jun 2026 06:43:12 +0000	[thread overview]
Message-ID: <20260629064342.7FB8B1F00A3A@smtp.kernel.org> (raw)
In-Reply-To: <akIR3WlKLCiCTb5T@stanley.mountain>

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

Pre-existing issues:
- [High] The error path unconditionally returns ERR_PTR(-ENOMEM), masking the actual error code from vmw_bo_create().
--

commit 97833dd848667c1ef6ccc7587272c584beab9fb5
Author: Dan Carpenter <error27@gmail.com>

drm/vmwgfx: Fix NULL vs error pointer bug in vmw_prime_import_sg_table()

The patch changes the initial value of gem in vmw_prime_import_sg_table()
from NULL to ERR_PTR(-ENOMEM) to prevent a NULL pointer dereference in the
caller when vmw_bo_create() fails.

> diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_gem.c b/drivers/gpu/drm/vmwgfx/vmwgfx_gem.c
> index 39f8c46550c27..f25db04f87778 100644
> --- a/drivers/gpu/drm/vmwgfx/vmwgfx_gem.c
> +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_gem.c
> @@ -184,7 +184,7 @@ struct drm_gem_object *vmw_prime_import_sg_table(struct drm_device *dev,
>  {
>  	int ret;
>  	struct vmw_private *dev_priv = vmw_priv(dev);
> -	struct drm_gem_object *gem = NULL;
> +	struct drm_gem_object *gem = ERR_PTR(-ENOMEM);

[Severity: High]
This is a pre-existing issue, but does hardcoding ERR_PTR(-ENOMEM) mask the
actual error returned by vmw_bo_create()?

When vmw_bo_create() fails, it returns an error code in the ret variable:

	ret = vmw_bo_create(dev_priv, &params, &vbo);
	if (ret != 0)
		goto out_no_bo;

Since gem is initialized to ERR_PTR(-ENOMEM) and never updated with ret before
jumping to out_no_bo, the actual error code is permanently lost.

If vmw_bo_create() is interrupted by a signal and returns -ERESTARTSYS,
masking it with -ENOMEM breaks the kernel's signal handling and syscall
restart mechanism. This could potentially cause unexpected failures in
userspace applications and compositors.

Could gem be updated to ERR_PTR(ret) in the error path instead?

>  	struct vmw_bo *vbo;
>  	struct vmw_bo_params params = {
>  		.domain = (dev_priv->has_mob) ? VMW_BO_DOMAIN_SYS : VMW_BO_DOMAIN_VRAM,

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/akIR3WlKLCiCTb5T@stanley.mountain?part=1

  reply	other threads:[~2026-06-29  6:43 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-29  6:34 [PATCH] drm/vmwgfx: Fix NULL vs error pointer bug in vmw_prime_import_sg_table() Dan Carpenter
2026-06-29  6:43 ` sashiko-bot [this message]
2026-06-29  7:11   ` Dan Carpenter
2026-07-01 18:43 ` Maaz Mombasawala

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=20260629064342.7FB8B1F00A3A@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=error27@gmail.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.