From: Ramalingam C <ramalingam.c@intel.com>
To: Matthew Auld <matthew.auld@intel.com>,
intel-gfx <intel-gfx@lists.freedesktop.org>,
dri-devel <dri-devel@lists.freedesktop.org>
Subject: [Intel-gfx] [PATCH] drm/i915/gt: handle null ptr at sg traversing
Date: Mon, 27 Jun 2022 23:05:39 +0530 [thread overview]
Message-ID: <20220627173539.29094-1-ramalingam.c@intel.com> (raw)
When calculating the starting address for ccs data in smem scatterlist,
handle the NULL pointer returned from sg_next, incase of scatterlist
less than required size..
Signed-off-by: Ramalingam C <ramalingam.c@intel.com>
---
drivers/gpu/drm/i915/gt/intel_migrate.c | 13 ++++++++++---
1 file changed, 10 insertions(+), 3 deletions(-)
diff --git a/drivers/gpu/drm/i915/gt/intel_migrate.c b/drivers/gpu/drm/i915/gt/intel_migrate.c
index 2c35324b5f68..c206fb4f4186 100644
--- a/drivers/gpu/drm/i915/gt/intel_migrate.c
+++ b/drivers/gpu/drm/i915/gt/intel_migrate.c
@@ -669,7 +669,7 @@ calculate_chunk_sz(struct drm_i915_private *i915, bool src_is_lmem,
}
}
-static void get_ccs_sg_sgt(struct sgt_dma *it, u32 bytes_to_cpy)
+static int get_ccs_sg_sgt(struct sgt_dma *it, u32 bytes_to_cpy)
{
u32 len;
@@ -684,9 +684,13 @@ static void get_ccs_sg_sgt(struct sgt_dma *it, u32 bytes_to_cpy)
bytes_to_cpy -= len;
it->sg = __sg_next(it->sg);
+ if (!it->sg)
+ return -EINVAL;
it->dma = sg_dma_address(it->sg);
it->max = it->dma + sg_dma_len(it->sg);
} while (bytes_to_cpy);
+
+ return 0;
}
int
@@ -745,8 +749,11 @@ intel_context_migrate_copy(struct intel_context *ce,
* Need to fix it.
*/
ccs_bytes_to_cpy = src_sz != dst_sz ? GET_CCS_BYTES(i915, bytes_to_cpy) : 0;
- if (ccs_bytes_to_cpy)
- get_ccs_sg_sgt(&it_ccs, bytes_to_cpy);
+ if (ccs_bytes_to_cpy) {
+ err = get_ccs_sg_sgt(&it_ccs, bytes_to_cpy);
+ if (err)
+ return err;
+ }
}
src_offset = 0;
--
2.20.1
next reply other threads:[~2022-06-27 17:34 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-06-27 17:35 Ramalingam C [this message]
2022-06-28 3:28 ` [Intel-gfx] ✓ Fi.CI.BAT: success for drm/i915/gt: handle null ptr at sg traversing Patchwork
2022-06-28 9:40 ` [Intel-gfx] [PATCH] " Matthew Auld
2022-06-28 9:59 ` Ramalingam C
2022-06-28 18:29 ` [Intel-gfx] ✗ Fi.CI.IGT: failure for " Patchwork
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=20220627173539.29094-1-ramalingam.c@intel.com \
--to=ramalingam.c@intel.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=intel-gfx@lists.freedesktop.org \
--cc=matthew.auld@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