diff mbox series

s390/cio: Fix how vfio-ccw checks pinned pages

Message ID 20181002010235.42483-1-farman@linux.ibm.com (mailing list archive)
State Mainlined
Headers show
Series s390/cio: Fix how vfio-ccw checks pinned pages | expand

Commit Message

Eric Farman Oct. 2, 2018, 1:02 a.m. UTC
We have two nested loops to check the entries within the pfn_array_table
arrays.  But we mistakenly use the outer array as an index in our check,
and completely ignore the indexing performed by the inner loop.

Signed-off-by: Eric Farman <farman@linux.ibm.com>
---
 drivers/s390/cio/vfio_ccw_cp.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Christian Borntraeger Oct. 2, 2018, 6:37 a.m. UTC | #1
On 10/02/2018 03:02 AM, Eric Farman wrote:
> We have two nested loops to check the entries within the pfn_array_table
> arrays.  But we mistakenly use the outer array as an index in our check,
> and completely ignore the indexing performed by the inner loop.
> 
> Signed-off-by: Eric Farman <farman@linux.ibm.com>

I think this qualifies for stable.

> ---
>  drivers/s390/cio/vfio_ccw_cp.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/s390/cio/vfio_ccw_cp.c b/drivers/s390/cio/vfio_ccw_cp.c
> index dbe7c7ac9ac8..fd77e46eb3b2 100644
> --- a/drivers/s390/cio/vfio_ccw_cp.c
> +++ b/drivers/s390/cio/vfio_ccw_cp.c
> @@ -163,7 +163,7 @@ static bool pfn_array_table_iova_pinned(struct pfn_array_table *pat,
>  
>  	for (i = 0; i < pat->pat_nr; i++, pa++)
>  		for (j = 0; j < pa->pa_nr; j++)
> -			if (pa->pa_iova_pfn[i] == iova_pfn)
> +			if (pa->pa_iova_pfn[j] == iova_pfn)
>  				return true;
>  
>  	return false;
>
Cornelia Huck Oct. 2, 2018, 8:03 a.m. UTC | #2
On Tue, 2 Oct 2018 08:37:06 +0200
Christian Borntraeger <borntraeger@de.ibm.com> wrote:

> On 10/02/2018 03:02 AM, Eric Farman wrote:
> > We have two nested loops to check the entries within the pfn_array_table
> > arrays.  But we mistakenly use the outer array as an index in our check,
> > and completely ignore the indexing performed by the inner loop.
> > 
> > Signed-off-by: Eric Farman <farman@linux.ibm.com>  
> 
> I think this qualifies for stable.

Agreed; queued with cc:stable added.

Thanks for looking into this; anything more in your queue, or should I
send another pull request soon?
Eric Farman Oct. 2, 2018, 12:52 p.m. UTC | #3
On 10/02/2018 04:03 AM, Cornelia Huck wrote:
> On Tue, 2 Oct 2018 08:37:06 +0200
> Christian Borntraeger <borntraeger@de.ibm.com> wrote:
> 
>> On 10/02/2018 03:02 AM, Eric Farman wrote:
>>> We have two nested loops to check the entries within the pfn_array_table
>>> arrays.  But we mistakenly use the outer array as an index in our check,
>>> and completely ignore the indexing performed by the inner loop.
>>>
>>> Signed-off-by: Eric Farman <farman@linux.ibm.com>
>>
>> I think this qualifies for stable.
> 
> Agreed; queued with cc:stable added.
> 
> Thanks for looking into this; anything more in your queue, or should I
> send another pull request soon?
> 

Sorry I didn't get this one out earlier :)

I do have some more in progress, but they're more involved and would 
probably generate some discussion.  Not sure when I'll get them finished 
up, so go ahead and generate the pull when convenient.  Thank you!
diff mbox series

Patch

diff --git a/drivers/s390/cio/vfio_ccw_cp.c b/drivers/s390/cio/vfio_ccw_cp.c
index dbe7c7ac9ac8..fd77e46eb3b2 100644
--- a/drivers/s390/cio/vfio_ccw_cp.c
+++ b/drivers/s390/cio/vfio_ccw_cp.c
@@ -163,7 +163,7 @@  static bool pfn_array_table_iova_pinned(struct pfn_array_table *pat,
 
 	for (i = 0; i < pat->pat_nr; i++, pa++)
 		for (j = 0; j < pa->pa_nr; j++)
-			if (pa->pa_iova_pfn[i] == iova_pfn)
+			if (pa->pa_iova_pfn[j] == iova_pfn)
 				return true;
 
 	return false;