From 4e171757017a9dd7183255d4680f256ec5e4b5d4 Mon Sep 17 00:00:00 2001 From: Ahmed Mansour Date: Tue, 19 May 2015 17:58:24 -0400 Subject: 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 Change-Id: I5939e7e6457e07e9355ba54fef80a7bc71c3a64b Reviewed-on: http://git.am.freescale.net:8181/36609 Tested-by: Review Code-CDREVIEW Reviewed-by: Mahammad Ismayilzada Reviewed-by: Honghua Yin 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 -- cgit v0.10.2