Skip to contentSkip to conversation

patch "staging: gasket: Check the return value of gasket_get_bar_index()" added to staging-linus

PATCH [email protected] 1 participant 1 message May 5, 2020

Subsystems (2)
lore
Share & tools
lore

[email protected]

author maintainer Applied
#0 lore raw

This is a note to let you know that I've just added the patch titled

staging: gasket: Check the return value of gasket_get_bar_index()

to my staging git tree which can be found at
git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging.git
in the staging-linus branch.

The patch will show up in the next release of the linux-next tree (usually sometime within the next 24 hours during the week.)

The patch will hopefully also be merged in Linus's tree for the next -rc kernel release.

If you have any questions about this process, please let me know.

From 769acc3656d93aaacada814939743361d284fd87 Mon Sep 17 00:00:00 2001
From: Oscar Carter <[email protected]>
Date: Fri, 1 May 2020 17:51:18 +0200
Subject: 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 9a69f5087ccc2 ("drivers/staging: Gasket driver framework + Apex driver")
Cc stable <[email protected]>
---
 drivers/staging/gasket/gasket_core.c | 4 ++++
 1 file changed, 4 insertions(+)
drivers/staging/gasket/gasket_core.c +4 -0
index 8e0575fcb4c8..67325fbaf760 100644
@@ -925,6 +925,10 @@ do_map_region(const struct gasket_dev *gasket_dev, struct vm_area_struct *vma,
 		gasket_get_bar_index(gasket_dev,
 				     (vma->vm_pgoff << PAGE_SHIFT) +
 				     driver_desc->legacy_mmap_address_offset);
+
+	if (bar_index < 0)
+		return DO_MAP_REGION_INVALID;
+
 	phys_base = gasket_dev->bar_data[bar_index].phys_base + phys_offset;
 	while (mapped_bytes < map_length) {
 		/*
Signature · 1 line
2.26.2