Subject: Re: [syzbot] INFO: task hung in port100_probe

From: Pavel Skripkin <[email-masked]>
Date: Tue, 22 Jun 2021 19:07:01 +0300

On Tue, 22 Jun 2021 08:43:29 -0700
syzbot <[email-masked]> wrote:

> Hello,
> 
> syzbot found the following issue on:
> 
> HEAD commit:    fd0aa1a4 Merge tag 'for-linus' of
> git://git.kernel.org/pub.. git tree:       upstream
> console output:
> https://syzkaller.appspot.com/x/log.txt?x=13e1500c300000 kernel
> config:  https://syzkaller.appspot.com/x/.config?x=7ca96a2d153c74b0
> dashboard link:
> https://syzkaller.appspot.com/bug?extid=abd2e0dafb481b621869 syz
> repro:
> https://syzkaller.appspot.com/x/repro.syz?x=1792e284300000 C
> reproducer:   https://syzkaller.appspot.com/x/repro.c?x=13ad9d48300000
> 
> IMPORTANT: if you fix the issue, please add the following tag to the
> commit: Reported-by:
> [email-masked]
> 
> INFO: task kworker/0:1:7 blocked for more than 143 seconds.
>       Not tainted 5.13.0-rc6-syzkaller #0
> "echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this
> message. task:kworker/0:1     state:D stack:25584 pid:    7 ppid:
> 2 flags:0x00004000 Workqueue: usb_hub_wq hub_event

Hmmm, maybe this will work

#syz test
git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master

With regards,
Pavel Skripkin
>From 450d464332a8dbf5a915c1447af554ca84a163bb Mon Sep 17 00:00:00 2001
From: Pavel Skripkin <[email-masked]>
Date: Tue, 22 Jun 2021 19:00:03 +0300
Subject: [PATCH] nfc: add missing complete() to avoid hung

/* .... */

Signed-off-by: Pavel Skripkin <[email-masked]>
---
 drivers/nfc/port100.c | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/drivers/nfc/port100.c b/drivers/nfc/port100.c
index 8e4d355dc3ae..c8c421af49b7 100644
--- a/drivers/nfc/port100.c
+++ b/drivers/nfc/port100.c
@@ -805,9 +805,15 @@ static void port100_build_cmd_frame(struct port100 *dev, u8 cmd_code,
 	port100_tx_frame_finish(skb->data);
 }
 
+struct port100_sync_cmd_response {
+	struct sk_buff *resp;
+	struct completion done;
+};
+
 static void port100_send_async_complete(struct port100 *dev)
 {
 	struct port100_cmd *cmd = dev->cmd;
+	struct port100_sync_cmd_response *cmd_resp = cmd->complete_cb_context;
 	int status = cmd->status;
 
 	struct sk_buff *req = cmd->req;
@@ -831,6 +837,7 @@ static void port100_send_async_complete(struct port100 *dev)
 	cmd->complete_cb(dev, cmd->complete_cb_context, resp);
 
 done:
+	complete(&cmd_resp->done);
 	kfree(cmd);
 }
 
@@ -883,11 +890,6 @@ static int port100_send_cmd_async(struct port100 *dev, u8 cmd_code,
 	return rc;
 }
 
-struct port100_sync_cmd_response {
-	struct sk_buff *resp;
-	struct completion done;
-};
-
 static void port100_wq_cmd_complete(struct work_struct *work)
 {
 	struct port100 *dev = container_of(work, struct port100,
-- 
2.32.0