fail non-blocking I/O in case of span unassignment
In case a user has a file descriptor that is used for non-blocking I/O and the span to which it belongs gets unassigned, its reads and writes will still yield -EAGAIN. This commit adds a test for such a case and returns the proper -ENODEV. Signed-off-by: Tzafrir Cohen <tzafrir.cohen@xorcom.com>
This commit is contained in:
parent
0159b0e7ce
commit
9c0002bf1f
@ -2414,6 +2414,9 @@ static ssize_t dahdi_chan_read(struct file *file, char __user *usrbuf,
|
||||
if (unlikely(count < 1))
|
||||
return -EINVAL;
|
||||
|
||||
if (unlikely(!test_bit(DAHDI_FLAGBIT_REGISTERED, &chan->flags)))
|
||||
return -ENODEV;
|
||||
|
||||
for (;;) {
|
||||
spin_lock_irqsave(&chan->lock, flags);
|
||||
if (chan->eventinidx != chan->eventoutidx) {
|
||||
@ -2531,6 +2534,9 @@ static ssize_t dahdi_chan_write(struct file *file, const char __user *usrbuf,
|
||||
if (unlikely(count < 1))
|
||||
return -EINVAL;
|
||||
|
||||
if (unlikely(!test_bit(DAHDI_FLAGBIT_REGISTERED, &chan->flags)))
|
||||
return -ENODEV;
|
||||
|
||||
for (;;) {
|
||||
spin_lock_irqsave(&chan->lock, flags);
|
||||
if ((chan->curtone || chan->pdialcount) && !is_pseudo_chan(chan)) {
|
||||
|
Loading…
Reference in New Issue
Block a user