summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAhmed Mansour <Ahmed.Mansour@freescale.com>2015-05-19 21:58:24 (GMT)
committerHonghua Yin <Hong-Hua.Yin@freescale.com>2015-05-21 03:22:37 (GMT)
commit4e171757017a9dd7183255d4680f256ec5e4b5d4 (patch)
treea21806c94dfd89401ec425e1de59e1d3981ded05
parenta43259698c278230c46e10996b9894a2a4ba7fda (diff)
downloadlinux-fsl-qoriq-4e171757017a9dd7183255d4680f256ec5e4b5d4.tar.xz
fsl_usdpaa: Protect against truncation
is_power_of_2 is a Linux function that takes unsigned long. it was used by our new function is_power_of_4 which takes u64. Trucation is possible because unsigned long is 32 bits wide in 32 bit applications. This patch removes the dependancy on is_power_of_2 to solve this issue Signed-off-by: Ahmed Mansour <Ahmed.Mansour@freescale.com> Change-Id: I5939e7e6457e07e9355ba54fef80a7bc71c3a64b Reviewed-on: http://git.am.freescale.net:8181/36609 Tested-by: Review Code-CDREVIEW <CDREVIEW@freescale.com> Reviewed-by: Mahammad Ismayilzada <mahammad.ismayilzada@freescale.com> Reviewed-by: Honghua Yin <Hong-Hua.Yin@freescale.com>
-rw-r--r--drivers/staging/fsl_qbman/fsl_usdpaa.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/drivers/staging/fsl_qbman/fsl_usdpaa.c b/drivers/staging/fsl_qbman/fsl_usdpaa.c
index dfef598..e2e3308 100644
--- a/drivers/staging/fsl_qbman/fsl_usdpaa.c
+++ b/drivers/staging/fsl_qbman/fsl_usdpaa.c
@@ -195,9 +195,9 @@ static u32 largest_page_size(u32 size)
/* Determine if value is power of 4 */
static inline bool is_power_of_4(u64 x)
{
- if (!is_power_of_2(x))
+ if (x == 0 || ((x & (x - 1)) != 0))
return false;
- return !!(x & 0x5555555555555555ul);
+ return !!(x & 0x5555555555555555ull);
}
/* Helper for ioctl_dma_map() when we have a larger fragment than we need. This