On Sun, Dec 13, 2020 at 03:29:38PM +0200, Leon Romanovsky wrote: > From: Shay Drory <shayd@xxxxxxxxxx> > > Currently, polling a umad device will always works, even if the device > was disassociated. Hence, returning EPOLLERR if device was > disassociated. Grammar: Currently, polling a umad device will always work, even if the device was disassociated. A disassociated device should immediately return EPOLLERR from poll() and EIO from any read()/write(). Otherwise userspace is endlessly hung on poll() with no idea that the device has been removed from the system. > Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2") > Signed-off-by: Shay Drory <shayd@xxxxxxxxxx> > Signed-off-by: Leon Romanovsky <leonro@xxxxxxxxxx> > drivers/infiniband/core/user_mad.c | 4 ++++ > 1 file changed, 4 insertions(+) > > diff --git a/drivers/infiniband/core/user_mad.c b/drivers/infiniband/core/user_mad.c > index b671d4aede77..6681e9cf8a18 100644 > +++ b/drivers/infiniband/core/user_mad.c > @@ -653,10 +653,14 @@ static __poll_t ib_umad_poll(struct file *filp, struct poll_table_struct *wait) > /* we will always be able to post a MAD send */ > __poll_t mask = EPOLLOUT | EPOLLWRNORM; > > + mutex_lock(&file->mutex); > poll_wait(filp, &file->recv_wait, wait); > > if (!list_empty(&file->recv_list)) > mask |= EPOLLIN | EPOLLRDNORM; > + if (file->agents_dead) > + mask = EPOLLERR; This also needs to trigger the recv_wait when agents_dead is set in ib_umad_kill_port() Jason