platform/chrome: cros_ec_chardev: Check ec_dev's availability in fops
It is possible that a userland program is waiting for further MKBP
events while the underlying ec_dev is already unregistered.
Check ec_dev's availability in the fops to avoid the userland program
from waiting for some events that should never happen.
Note: if the userland program uses poll() without a timeout, e.g.:
: fd = os.open('/dev/cros_ec', os.O_RDONLY)
: fcntl.ioctl(fd, 0xec02, 0xfff)
: p = select.poll()
: p.register(fd, select.POLLIN)
:
: while True:
: es = p.poll() # <--- without a timeout
: if not es:
: print("no events")
: continue
:
: for f, e in es:
: if e & select.POLLIN:
: data = os.read(f, 100)
: print(data)
It'd still block. The patch doesn't help with the case.
Signed-off-by: Tzung-Bi Shih <tzungbi@kernel.org>
1 file changed