source: trunk/target/linux/generic/patches-3.3/993-mpcore_wdt_fix_wdioc_setoptions_handling.patch @ 29986

Last change on this file since 29986 was 29986, checked in by jogo, 4 years ago

kernel: add preliminary support for linux 3.3

Based on 3.3-rc2

File size: 1.1 KB
  • drivers/watchdog/mpcore_wdt.c

    According to the include/linux/watchdog.h WDIOC_SETOPTIONS is
    classified as 'read from device' ioctl call:
      #define WDIOC_SETOPTIONS        _IOR(WATCHDOG_IOCTL_BASE, 4, int)
    
    However, the driver 'mpcore_wdt' performs 'copy_from_user' only if
    _IOC_WRITE is set, thus the local variable 'uarg' which is used in
    WDIOC_SETOPTIONS handling remains uninitialized.
    
    The proper way to fix this is to bind WDIOC_SETOPTIONS to _IOW,
    but this will break compatibility.
    So adding additional condition for performing 'copy_from_user'.
    
    Signed-off-by: Vitaly Kuzmichev <vkuzmichev@mvista.com>
    ---
     drivers/watchdog/mpcore_wdt.c |    3 ++-
     1 files changed, 2 insertions(+), 1 deletions(-)
    
    a b static long mpcore_wdt_ioctl(struct file 
    233233        if (_IOC_DIR(cmd) && _IOC_SIZE(cmd) > sizeof(uarg)) 
    234234                return -ENOTTY; 
    235235 
    236         if (_IOC_DIR(cmd) & _IOC_WRITE) { 
     236        if ((_IOC_DIR(cmd) & _IOC_WRITE) 
     237                        || cmd == WDIOC_SETOPTIONS) { 
    237238                ret = copy_from_user(&uarg, (void __user *)arg, _IOC_SIZE(cmd)); 
    238239                if (ret) 
    239240                        return -EFAULT; 
Note: See TracBrowser for help on using the repository browser.