Patch "pinctrl: ingenic: Improve unreachable code generation" has been added to the 5.4-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    pinctrl: ingenic: Improve unreachable code generation

to the 5.4-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     pinctrl-ingenic-improve-unreachable-code-generation.patch
and it can be found in the queue-5.4 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit 8f9a7c4fcace60b85f6975e9c78b3f90782f9380
Author: Josh Poimboeuf <jpoimboe@xxxxxxxxxx>
Date:   Thu Feb 20 09:35:09 2020 -0600

    pinctrl: ingenic: Improve unreachable code generation
    
    [ Upstream commit d6d43a92172085a2681e06a0d06aac53c7bcdd12 ]
    
    In the second loop of ingenic_pinconf_set(), it annotates the switch
    default case as unreachable().  The annotation is technically correct,
    because that same case would have resulted in an early function return
    in the previous loop.
    
    However, the compiled code is suboptimal.  GCC seems to work extra hard
    to ensure that the unreachable code path triggers undefined behavior.
    The function would fall through to start executing whatever function
    happens to be next in the compilation unit.
    
    This is problematic because:
    
      a) it adds unnecessary 'ensure undefined behavior' logic, and
         corresponding i-cache footprint; and
    
      b) it's less robust -- if a bug were to be introduced, falling through
         to the next function would be catastrophic.
    
    Yet another issue is that, while objtool normally understands
    unreachable() annotations, there's one special case where it doesn't:
    when the annotation occurs immediately after a 'ret' instruction.  That
    happens to be the case here because unreachable() is immediately before
    the return.
    
    Remove the unreachable() annotation and replace it with a comment.  This
    simplifies the code generation and changes the unreachable error path to
    just silently return instead of corrupting execution.
    
    This fixes the following objtool warning:
    
      drivers/pinctrl/pinctrl-ingenic.o: warning: objtool: ingenic_pinconf_set() falls through to next function ingenic_pinconf_group_set()
    
    Reported-by: Randy Dunlap <rdunlap@xxxxxxxxxxxxx>
    Signed-off-by: Josh Poimboeuf <jpoimboe@xxxxxxxxxx>
    Link: https://lore.kernel.org/r/bc20fdbcb826512cf76b7dfd0972740875931b19.1582212881.git.jpoimboe@xxxxxxxxxx
    Signed-off-by: Linus Walleij <linus.walleij@xxxxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/drivers/pinctrl/pinctrl-ingenic.c b/drivers/pinctrl/pinctrl-ingenic.c
index 61e7d938d4c5..91596eee0bda 100644
--- a/drivers/pinctrl/pinctrl-ingenic.c
+++ b/drivers/pinctrl/pinctrl-ingenic.c
@@ -1846,7 +1846,8 @@ static int ingenic_pinconf_set(struct pinctrl_dev *pctldev, unsigned int pin,
 			break;
 
 		default:
-			unreachable();
+			/* unreachable */
+			break;
 		}
 	}
 



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux