[PATCH] MIPS: op_model_mipsxx: Fix non-executable code bug

"Gustavo A. R. Silva" <[email protected]> Tue, 18 Aug 2020 23:58:13 -0500
Newsgroups gmane.linux.ports.mips,gmane.linux.oprofile,gmane.linux.kernel
Message-ID <20200819045813.GA24181@embeddedor>
The fallthrough pseudo-keyword is being wrongly used and is causing
the non-executable code error below:

arch/mips/oprofile/op_model_mipsxx.c: In function ‘mipsxx_perfcount_handler’:
./include/linux/compiler_attributes.h:214:41: warning: statement will never be executed [-Wswitch-unreachable]
 # define fallthrough                    __attribute__((__fallthrough__))
                                         ^
arch/mips/oprofile/op_model_mipsxx.c:248:2: note: in expansion of macro ‘fallthrough’
  fallthrough;       \
  ^~~~~~~~~~~
arch/mips/oprofile/op_model_mipsxx.c:258:2: note: in expansion of macro ‘HANDLE_COUNTER’
  HANDLE_COUNTER(3)
  ^~~~~~~~~~~~~~

Fix this by placing the fallthrough macro at the proper place.

Fixes: c9b029903466 ("MIPS: Use fallthrough for arch/mips")
Cc: [email protected]
Signed-off-by: Gustavo A. R. Silva <[email protected]>
---
 arch/mips/oprofile/op_model_mipsxx.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/mips/oprofile/op_model_mipsxx.c b/arch/mips/oprofile/op_model_mipsxx.c
index 1493c49ca47a..f200b97bdef7 100644
--- a/arch/mips/oprofile/op_model_mipsxx.c
+++ b/arch/mips/oprofile/op_model_mipsxx.c
@@ -245,7 +245,6 @@ static int mipsxx_perfcount_handler(void)
 
 	switch (counters) {
 #define HANDLE_COUNTER(n)						\
-	fallthrough;							\
 	case n + 1:							\
 		control = r_c0_perfctrl ## n();				\
 		counter = r_c0_perfcntr ## n();				\
@@ -254,7 +253,8 @@ static int mipsxx_perfcount_handler(void)
 			oprofile_add_sample(get_irq_regs(), n);		\
 			w_c0_perfcntr ## n(reg.counter[n]);		\
 			handled = IRQ_HANDLED;				\
-		}
+		}							\
+	fallthrough;
 	HANDLE_COUNTER(3)
 	HANDLE_COUNTER(2)
 	HANDLE_COUNTER(1)
-- 
2.27.0