Menu

#249 Some ioctl()/fcntl() calls lack error handling...

None
closed-fixed
nobody
None
5
2021-09-29
2019-09-05
No

There are a few calls to ioctl()/fcntl() in fgPlatformJoystickOpen() that lacks error handling. The attached patch adds this. I attempted to follow your coding style. Let me know what you think and whether I can do anything to get this merged quicker. :)

1 Attachments

Discussion

  • John Tsiombikas

    John Tsiombikas - 2019-09-11

    I don't see what good returning at this point does. First of all JSIOCGAXES and JSIOCGBUTTONS ioctl can't fail. The code in the kernel is simply:

    case JSIOCGAXES:
        return put_user(joydev->nabs, (__u8 __user *) argp);
    
    case JSIOCGBUTTONS:
        return put_user(joydev->nkey, (__u8 __user *) argp);
    

    But even if it could fail, we don't want to return there, we'd want to just avoid clobbering the num_axes/num_buttons variables with the undefined value in u.

    JSIOCGNAME can fail, but in that case we certainly don't wont to just return and skip the rest of the function. Simply leaving a default name, is absolutely fine. We just need to make sure there's always a sane default there too.

    Setting the O_NONBLOCK flag with fcntl(... F_SETFL, O_NONBLOCK) also can't possibly fail if we do it correctly. Here we're not doing it correctly. O_NONBLOCK should be or-ed with the current flags, not override them completely. But still it won't fail.

    I'm leaving this open for now, to remember to fix these issues I identified while looking into it.

     
  • John Tsiombikas

    John Tsiombikas - 2021-09-29
    • status: open --> closed-fixed
    • Group: -->
     

Log in to post a comment.