[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20200504174933.GA83381@google.com>
Date: Mon, 4 May 2020 13:49:33 -0400
From: Richard Yeh <rcy@...gle.com>
To: Oscar Carter <oscar.carter@....com>
Cc: Rob Springer <rspringer@...gle.com>,
Todd Poynor <toddpoynor@...gle.com>,
Ben Chan <benchan@...omium.org>,
Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
Simon Que <sque@...omium.org>,
John Joseph <jnjoseph@...gle.com>, devel@...verdev.osuosl.org,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH] staging: gasket: Check the return value of
gasket_get_bar_index()
On Fri, May 01, 2020 at 05:51:18PM +0200, Oscar Carter wrote:
> 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")
> Signed-off-by: Oscar Carter <oscar.carter@....com>
> ---
> drivers/staging/gasket/gasket_core.c | 4 ++++
> 1 file changed, 4 insertions(+)
>
> diff --git a/drivers/staging/gasket/gasket_core.c b/drivers/staging/gasket/gasket_core.c
> index 8e0575fcb4c8..67325fbaf760 100644
> --- a/drivers/staging/gasket/gasket_core.c
> +++ b/drivers/staging/gasket/gasket_core.c
> @@ -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) {
> /*
> --
> 2.20.1
>
Reviewed-by: Richard Yeh <rcy@...gle.com>
Powered by blists - more mailing lists