Skip to content

Commit

Permalink
parport_pc: fix find_superio io compare code, should use equal test.
Browse files Browse the repository at this point in the history
In the original code before 181bf1e the loop was continuing until
it finds the first matching superios[i].io and p->base.
But after 181bf1e the logic changed and the loop now returns the
pointer to the first mismatched array element which is then used in
get_superio_dma() and get_superio_irq() and thus returning the wrong
value.
Fix the condition so that it now returns the correct pointer.

Fixes: 181bf1e ("parport_pc: clean up the modified while loops using for")
Cc: Alan Cox <alan@linux.intel.com>
Cc: stable@vger.kernel.org
Signed-off-by: QiaoChong <qiaochong@loongson.cn>
[rewrite the commit message]
Signed-off-by: Sudip Mukherjee <sudipm.mukherjee@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
QiaoChong authored and Greg Kroah-Hartman committed Feb 11, 2019
1 parent 492b7a8 commit 21698fd
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion drivers/parport/parport_pc.c
Original file line number Diff line number Diff line change
Expand Up @@ -1377,7 +1377,7 @@ static struct superio_struct *find_superio(struct parport *p)
{
int i;
for (i = 0; i < NR_SUPERIOS; i++)
if (superios[i].io != p->base)
if (superios[i].io == p->base)
return &superios[i];
return NULL;
}
Expand Down

0 comments on commit 21698fd

Please sign in to comment.