Skip to content

Commit 769acc3

Browse files
Oscar Cartergregkh
authored andcommitted
staging: gasket: Check the return value of gasket_get_bar_index()
Check the return value of gasket_get_bar_index function as it can return a negative one (-EINVAL). If this happens, a negative index is used in the "gasket_dev->bar_data" array. Addresses-Coverity-ID: 1438542 ("Negative array index read") Fixes: 9a69f50 ("drivers/staging: Gasket driver framework + Apex driver") Signed-off-by: Oscar Carter <[email protected]> Cc: stable <[email protected]> Reviewed-by: Richard Yeh <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 3c5c080 commit 769acc3

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

drivers/staging/gasket/gasket_core.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -925,6 +925,10 @@ do_map_region(const struct gasket_dev *gasket_dev, struct vm_area_struct *vma,
925925
gasket_get_bar_index(gasket_dev,
926926
(vma->vm_pgoff << PAGE_SHIFT) +
927927
driver_desc->legacy_mmap_address_offset);
928+
929+
if (bar_index < 0)
930+
return DO_MAP_REGION_INVALID;
931+
928932
phys_base = gasket_dev->bar_data[bar_index].phys_base + phys_offset;
929933
while (mapped_bytes < map_length) {
930934
/*

0 commit comments

Comments
 (0)