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:54:08 +0000 (14:54 -0700)
commit3659bb266d2b84f868e31fd6f94ee338322aa5ff
treef87e208bfcb25ec4b31b94fc5e2d0747438846cb
parent9f9e0bc250e49796aac5e50abcc55b73590a57ec
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