summaryrefslogtreecommitdiff
path: root/sys/dev/pci
diff options
context:
space:
mode:
authorJonathan Gray <jsg@cvs.openbsd.org>2020-06-26 04:51:52 +0000
committerJonathan Gray <jsg@cvs.openbsd.org>2020-06-26 04:51:52 +0000
commit1739fe55fa2dadfc29a313cb55e5cc945afd965c (patch)
tree115de914c135c537b3687bf72a10677167ffa686 /sys/dev/pci
parent2f494369ff839b2b7fbc38e2e33a13a595739c9a (diff)
drm/i915/gem: Avoid iterating an empty list
From Chris Wilson 42765cb3887c2eea8a65f665a58f42b4ee6333c1 in linux 5.7.y/5.7.6 757a9395f33c51c4e6eff2c7c0fbd50226a58224 in mainline linux
Diffstat (limited to 'sys/dev/pci')
-rw-r--r--sys/dev/pci/drm/i915/gem/i915_gem_shmem.c15
1 files changed, 9 insertions, 6 deletions
diff --git a/sys/dev/pci/drm/i915/gem/i915_gem_shmem.c b/sys/dev/pci/drm/i915/gem/i915_gem_shmem.c
index 3c5182c2dd4..537c92e5242 100644
--- a/sys/dev/pci/drm/i915/gem/i915_gem_shmem.c
+++ b/sys/dev/pci/drm/i915/gem/i915_gem_shmem.c
@@ -43,7 +43,6 @@ static int shmem_get_pages(struct drm_i915_gem_object *obj)
unsigned long last_pfn = 0; /* suppress gcc warning */
unsigned int max_segment = i915_sg_segment_size();
unsigned int sg_page_sizes;
- struct pagevec pvec;
gfp_t noreclaim;
int ret;
@@ -225,13 +224,17 @@ err_sg:
sg_mark_end(sg);
err_pages:
mapping_clear_unevictable(mapping);
- pagevec_init(&pvec);
- for_each_sgt_page(page, sgt_iter, st) {
- if (!pagevec_add(&pvec, page))
+ if (sg != st->sgl) {
+ struct pagevec pvec;
+
+ pagevec_init(&pvec);
+ for_each_sgt_page(page, sgt_iter, st) {
+ if (!pagevec_add(&pvec, page))
+ check_release_pagevec(&pvec);
+ }
+ if (pagevec_count(&pvec))
check_release_pagevec(&pvec);
}
- if (pagevec_count(&pvec))
- check_release_pagevec(&pvec);
#else
err_pages:
uvm_objunwire(obj->base.uao, 0, obj->base.size);