diff options
author | Konstantin Vyshetsky <vkon@google.com> | 2023-11-17 14:02:59 -0800 |
---|---|---|
committer | Treehugger Robot <android-test-infra-autosubmit@system.gserviceaccount.com> | 2023-11-27 17:46:39 +0000 |
commit | 3cf0e75825c02b96a85cbfd14f069820ac28de47 (patch) | |
tree | 2eb47d5a408dd20be67bda0732e6105a6f49620d | |
parent | 8114c5bfec82897f7e606facc5e2f13932dfa669 (diff) | |
download | gs-3cf0e75825c02b96a85cbfd14f069820ac28de47.tar.gz |
ufs: fix desired_power_mode parameter validation
Original implementation could allow for incorrect value to be accepted
if the shift was over 32 bits.
Bug: 309660605
Change-Id: I08e616441c2a34cf8a26f3f09331950d1abfb0a5
Signed-off-by: Konstantin Vyshetsky <vkon@google.com>
(cherry picked from commit c88ecbd13f4cb45610123c08ac65f6c7c6e03c5e)
-rw-r--r-- | drivers/ufs/ufs-exynos.c | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/drivers/ufs/ufs-exynos.c b/drivers/ufs/ufs-exynos.c index ed47b063b..586059c3f 100644 --- a/drivers/ufs/ufs-exynos.c +++ b/drivers/ufs/ufs-exynos.c @@ -34,14 +34,14 @@ module_param(desired_power_mode_gear, uint, 0444); MODULE_PARM_DESC(desired_power_mode_gear, "Target UFS HS/PWM Gear, " "0 ( = not set) " "1-4 ( = use specified gear)"); -#define POWER_MODE_GEAR_VALID(x) (0x1E & (1 << (x))) +#define POWER_MODE_GEAR_VALID(x) ((x) && ((x) <= 4)) static unsigned int desired_power_mode_lane; module_param(desired_power_mode_lane, uint, 0444); MODULE_PARM_DESC(desired_power_mode_lane, "Target UFS Number of Lanes, " - "0 ( = not set)" + "0 ( = not set) " "1-2 ( = use specified num lanes)"); -#define POWER_MODE_LANE_VALID(x) (0x6 & (1 << (x))) +#define POWER_MODE_LANE_VALID(x) ((x) && ((x) <= 2)) static unsigned int desired_power_mode_pwr; module_param(desired_power_mode_pwr, uint, 0444); @@ -51,7 +51,7 @@ MODULE_PARM_DESC(desired_power_mode_pwr, "Target UFS PA Power Mode, " "2 ( = SLOW_MODE) " "4 ( = FASTAUTO_MODE) " "5 ( = SLOWAUTO_MODE)"); -#define POWER_MODE_PWR_VALID(x) (0x36 & (1 << (x))) +#define POWER_MODE_PWR_VALID(x) (((x) <= 5) && (0x36 & (1 << (x)))) static unsigned int desired_power_mode_hs_rate; module_param(desired_power_mode_hs_rate, uint, 0444); @@ -59,7 +59,7 @@ MODULE_PARM_DESC(desired_power_mode_hs_rate, "Target UFS HS Series, " "0 ( = not set) " "1 ( = HS Series A) " "2 ( = HS Series B)"); -#define POWER_MODE_HS_RATE_VALID(x) (0x6 & (1 << (x))) +#define POWER_MODE_HS_RATE_VALID(x) ((x) && ((x) <= 2)) #define IS_C_STATE_ON(h) ((h)->c_state == C_ON) #define PRINT_STATES(h) \ |