xtensa: fix address checks in dma_{alloc,free}_coherent
authorAlan Douglas <adouglas@cadence.com>
Wed, 23 Jul 2014 10:06:40 +0000 (14:06 +0400)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sun, 5 Oct 2014 21:52:13 +0000 (14:52 -0700)
commitba93d7c0214647c1ffbcfb5786e817a867c1f28c
treebf995d1bc37d043ce92df1b4d029ad743e0d6df6
parentd9aa5003f98fad024ffd8f93e2cadcfd9905e7de
xtensa: fix address checks in dma_{alloc,free}_coherent

commit 1ca49463c44c970b1ab1d71b0f268bfdf8427a7e upstream.

Virtual address is translated to the XCHAL_KSEG_CACHED region in the
dma_free_coherent, but is checked to be in the 0...XCHAL_KSEG_SIZE
range.

Change check for end of the range from 'addr >= X' to 'addr > X - 1' to
handle the case of X == 0.

Replace 'if (C) BUG();' construct with 'BUG_ON(C);'.

Signed-off-by: Alan Douglas <adouglas@cadence.com>
Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
arch/xtensa/kernel/pci-dma.c