• Arnd Bergmann's avatar
    tc358743: fix register i2c_rd/wr functions · f9e55370
    Arnd Bergmann authored
    commit 3538aa6e upstream.
    
    While testing with CONFIG_UBSAN, I got this warning:
    
    drivers/media/i2c/tc358743.c: In function 'tc358743_probe':
    drivers/media/i2c/tc358743.c:1930:1: error: the frame size of 2480 bytes is larger than 2048 bytes [-Werror=frame-larger-than=]
    
    The problem is that the i2c_rd8/wr8/rd16/... functions in this driver pass
    a pointer to a local variable into a common function, and each call to one
    of them adds another variable plus redzone to the stack.
    
    I also noticed that the way this is done is broken on big-endian machines,
    as we copy the registers in CPU byte order.
    
    To address both those problems, I'm adding two helper functions for reading
    a register of up to 32 bits with correct endianess and change all other
    functions to use that instead. Just to be sure we don't get the problem
    back with changed optimizations in gcc, I'm also marking the new functions
    as 'noinline', although my tests with gcc-7 don't require that.
    Signed-off-by: default avatarArnd Bergmann <arnd@arndb.de>
    Signed-off-by: default avatarHans Verkuil <hans.verkuil@cisco.com>
    Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@s-opensource.com>
    Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
    f9e55370
tc358743.c 53.4 KB