Skip to content

Commit 1da570d

Browse files
matthew-gerlachfpgamatt
authored andcommitted
fpga: dfl-cxl-cache: fix check of return of vma_lookup()
The function, vma_lookup, return NULL on error, not PTR_ERR. Fix the error handling accordingly. This problem was reported by Coverity. Signed-off-by: Matthew Gerlach <matthew.gerlach@linux.intel.com
1 parent fdf99b5 commit 1da570d

1 file changed

Lines changed: 4 additions & 6 deletions

File tree

drivers/fpga/dfl-cxl-cache.c

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -270,13 +270,11 @@ static long cxl_cache_set_region_read_only(struct dfl_cxl_cache *cxl_cache,
270270
struct dfl_cxl_cache_buffer_region *region)
271271
{
272272
struct vm_area_struct *vma;
273-
long ret = 0;
274273

275274
vma = vma_lookup(current->mm, region->user_addr);
276-
if (IS_ERR(vma)) {
277-
ret = PTR_ERR(vma);
278-
dev_err(cxl_cache->dev, "vma_lookup() failed: %ld\n", ret);
279-
return ret;
275+
if (!vma) {
276+
dev_err(cxl_cache->dev, "vma_lookup() failed\n");
277+
return -EINVAL;
280278
}
281279

282280
mmap_write_lock(current->mm);
@@ -292,7 +290,7 @@ static long cxl_cache_set_region_read_only(struct dfl_cxl_cache *cxl_cache,
292290
/* Flush all remaining cache entries. */
293291
drm_clflush_virt_range(page_address(region->pages[0]), region->length);
294292

295-
return ret;
293+
return 0;
296294
}
297295

298296
static long cxl_cache_ioctl_numa_buffer_map(struct dfl_cxl_cache *cxl_cache, void __user *arg)

0 commit comments

Comments
 (0)