From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-17.0 required=3.0 tests=BAYES_00,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C4622C433FE for ; Sun, 13 Dec 2020 13:31:05 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8A34420728 for ; Sun, 13 Dec 2020 13:31:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2394648AbgLMNaj (ORCPT ); Sun, 13 Dec 2020 08:30:39 -0500 Received: from mail.kernel.org ([198.145.29.99]:53438 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725890AbgLMNad (ORCPT ); Sun, 13 Dec 2020 08:30:33 -0500 From: Leon Romanovsky Authentication-Results: mail.kernel.org; dkim=permerror (bad message/signature format) To: Doug Ledford , Jason Gunthorpe Cc: Shay Drory , linux-rdma@vger.kernel.org Subject: [PATCH rdma-rc 3/5] IB/umad: Return EPOLLERR in case of when device disassociated Date: Sun, 13 Dec 2020 15:29:38 +0200 Message-Id: <20201213132940.345554-4-leon@kernel.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201213132940.345554-1-leon@kernel.org> References: <20201213132940.345554-1-leon@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org From: Shay Drory Currently, polling a umad device will always works, even if the device was disassociated. Hence, returning EPOLLERR if device was disassociated. Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2") Signed-off-by: Shay Drory Signed-off-by: Leon Romanovsky --- 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 --- a/drivers/infiniband/core/user_mad.c +++ 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; + mutex_unlock(&file->mutex); return mask; } -- 2.29.2