[PATCH 06/11] net/9p/usbg: add timeout for usbg_request
Michael Grzeschik <[email protected]>
| Newsgroups | dev.linux.lists.v9fs,org.kernel.vger.linux-kernel |
|---|---|
| Message-ID | <[email protected]> |
Move to wait_for_completion_killable_timeout to ensure that a pending mount will not hang in there forever. If the host side is not available after some time, the pending mount will come back with -ETIMEDOUT. Signed-off-by: Michael Grzeschik <[email protected]> --- net/9p/trans_usbg.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/net/9p/trans_usbg.c b/net/9p/trans_usbg.c index 472f7452794d7ac0f7b1475f0da2f4605a28e062..c764e06ad4bf7ef7266160b06063a4a98226649c 100644 --- a/net/9p/trans_usbg.c +++ b/net/9p/trans_usbg.c @@ -502,14 +502,21 @@ static void p9_usbg_close(struct p9_client *client) static int p9_usbg_request(struct p9_client *client, struct p9_req_t *p9_req) { struct f_usb9pfs *usb9pfs = client->trans; + struct usb_composite_dev *cdev = + usb9pfs->function.config->cdev; int ret; if (client->status != Connected) return -EBUSY; - ret = wait_for_completion_killable(&usb9pfs->send); - if (ret) + ret = wait_for_completion_killable_timeout(&usb9pfs->send, HZ * 10); + if (ret < 0) return ret; + if (!ret) { + dev_err(&cdev->gadget->dev, + "timeout while transferring 9p via usb\n"); + return -ETIMEDOUT; + } ret = usb9pfs_transmit(usb9pfs, p9_req); if (ret) -- 2.47.3