From 9c0002bf1f39dd04f19fc18e26505a7277d77386 Mon Sep 17 00:00:00 2001 From: Tzafrir Cohen Date: Mon, 19 Jun 2017 15:13:06 +0300 Subject: [PATCH] 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 --- drivers/dahdi/dahdi-base.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/dahdi/dahdi-base.c b/drivers/dahdi/dahdi-base.c index 305ea67..618754d 100644 --- a/drivers/dahdi/dahdi-base.c +++ b/drivers/dahdi/dahdi-base.c @@ -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)) {