From 36a30662f58838f450fe3e14bfeed8f4bf0cd973 Mon Sep 17 00:00:00 2001 From: Hemant Kumar Date: Tue, 15 Jun 2021 14:59:17 -0700 Subject: [PATCH] mhi: core: Fix find_last_bit() usage find_last_bit() relies on unsigned long pointer arguments. Driver uses a type cast that generates the KASAN warning. Replace find_last_bit() with __fls() to pass the value and avoid casting pointer to make the warning go away. Change-Id: I247e5c425ba0c44d04b518bd6d4f351f9c700b29 Signed-off-by: Hemant Kumar --- drivers/bus/mhi/core/mhi_init.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/drivers/bus/mhi/core/mhi_init.c b/drivers/bus/mhi/core/mhi_init.c index 526d7fd140e8..f026131cf3ab 100644 --- a/drivers/bus/mhi/core/mhi_init.c +++ b/drivers/bus/mhi/core/mhi_init.c @@ -92,9 +92,12 @@ struct mhi_controller *find_mhi_controller_by_name(const char *name) const char *to_mhi_pm_state_str(enum MHI_PM_STATE state) { - int index = find_last_bit((unsigned long *)&state, 32); + int index; - if (index >= ARRAY_SIZE(mhi_pm_state_str)) + if (state) + index = __fls(state); + + if (!state || index >= ARRAY_SIZE(mhi_pm_state_str)) return "Invalid State"; return mhi_pm_state_str[index];