diff mbox series

i915: Fix uninitialized variable err

Message ID 20210329134350.94536-1-colin.king@canonical.com (mailing list archive)
State New, archived
Headers show
Series i915: Fix uninitialized variable err | expand

Commit Message

Colin King March 29, 2021, 1:43 p.m. UTC
From: Colin Ian King <colin.king@canonical.com>

In the case where !sg_dma_len(sgl) breaks out of the do-while loop
on the first iteration, error variable err has not been assigned
any value and will contain garbage. Fix this by ensuring err is
initialized to zero.

Addresses-Coverity: ("Uninitialized scalar variable")
Fixes: 204302d90503 ("i915: fix remap_io_sg to verify the pgprot")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
 drivers/gpu/drm/i915/i915_mm.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/drivers/gpu/drm/i915/i915_mm.c b/drivers/gpu/drm/i915/i915_mm.c
index 4c8cd08c672d..25576fa73ff0 100644
--- a/drivers/gpu/drm/i915/i915_mm.c
+++ b/drivers/gpu/drm/i915/i915_mm.c
@@ -47,7 +47,7 @@  int remap_io_sg(struct vm_area_struct *vma,
 		struct scatterlist *sgl, resource_size_t iobase)
 {
 	unsigned long pfn, len, remapped = 0;
-	int err;
+	int err = 0;
 
 	/* We rely on prevalidation of the io-mapping to skip track_pfn(). */
 	GEM_BUG_ON((vma->vm_flags & EXPECTED_FLAGS) != EXPECTED_FLAGS);