From: "Thomas Hellström" <thomas.hellstrom@linux.intel.com>
To: Colin King <colin.king@canonical.com>,
Jani Nikula <jani.nikula@linux.intel.com>,
Joonas Lahtinen <joonas.lahtinen@linux.intel.com>,
Rodrigo Vivi <rodrigo.vivi@intel.com>,
David Airlie <airlied@linux.ie>, Daniel Vetter <daniel@ffwll.ch>,
Matthew Auld <matthew.auld@intel.com>,
intel-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org
Cc: kernel-janitors@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH][next] drm/i915: Fix dereference of pointer backup before it is null checked
Date: Tue, 12 Oct 2021 16:47:24 +0200 [thread overview]
Message-ID: <c49654d9-7174-f6db-e64b-bec3ecde7b5c@linux.intel.com> (raw)
In-Reply-To: <20211012132549.260089-1-colin.king@canonical.com>
Hi,
On 10/12/21 15:25, Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
>
> The assignment of pointer backup_bo dereferences pointer backup before
> backup is null checked, this could lead to a null pointer dereference
> issue. Fix this by only assigning backup_bo after backup has been null
> checked.
>
> Addresses-Coverity: ("Dereference before null check")
> Fixes: c56ce9565374 ("drm/i915 Implement LMEM backup and restore for suspend / resume")
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
There's not really a pointer dereference here, just pointer arithmetics,
so the code should be safe (but admittedly fragile), so to keep Coverity
happy,
Reviewed-by: Thomas Hellström <thomas.hellstrom@linux.intel.com>
> ---
> drivers/gpu/drm/i915/gem/i915_gem_ttm_pm.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/i915/gem/i915_gem_ttm_pm.c b/drivers/gpu/drm/i915/gem/i915_gem_ttm_pm.c
> index 3b6d14b5c604..4ec6c557083a 100644
> --- a/drivers/gpu/drm/i915/gem/i915_gem_ttm_pm.c
> +++ b/drivers/gpu/drm/i915/gem/i915_gem_ttm_pm.c
> @@ -149,7 +149,7 @@ static int i915_ttm_restore(struct i915_gem_apply_to_region *apply,
> struct i915_gem_ttm_pm_apply *pm_apply =
> container_of(apply, typeof(*pm_apply), base);
> struct drm_i915_gem_object *backup = obj->ttm.backup;
> - struct ttm_buffer_object *backup_bo = i915_gem_to_ttm(backup);
> + struct ttm_buffer_object *backup_bo;
> struct ttm_operation_ctx ctx = {};
> int err;
>
> @@ -163,6 +163,8 @@ static int i915_ttm_restore(struct i915_gem_apply_to_region *apply,
> if (err)
> return err;
>
> + backup_bo = i915_gem_to_ttm(backup);
> +
> /* Content may have been swapped. */
> err = ttm_tt_populate(backup_bo->bdev, backup_bo->ttm, &ctx);
> if (!err) {
next prev parent reply other threads:[~2021-10-12 14:47 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-10-12 13:25 [PATCH][next] drm/i915: Fix dereference of pointer backup before it is null checked Colin King
2021-10-12 14:47 ` Thomas Hellström [this message]
2021-10-12 15:12 ` Dan Carpenter
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=c49654d9-7174-f6db-e64b-bec3ecde7b5c@linux.intel.com \
--to=thomas.hellstrom@linux.intel.com \
--cc=airlied@linux.ie \
--cc=colin.king@canonical.com \
--cc=daniel@ffwll.ch \
--cc=dri-devel@lists.freedesktop.org \
--cc=intel-gfx@lists.freedesktop.org \
--cc=jani.nikula@linux.intel.com \
--cc=joonas.lahtinen@linux.intel.com \
--cc=kernel-janitors@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=matthew.auld@intel.com \
--cc=rodrigo.vivi@intel.com \
/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;
as well as URLs for NNTP newsgroup(s).