🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #7760

[PATCH v2 1/2] nfc: pn533: complete failed queued commands and keep queue moving

#7760
From: Zhao Feng
Date: Tue, 27 Oct 2026 07:01
50 lines
10392 bytes
When pn533_wq_cmd() fails to send a queued command it silently drops
it: the completion callback is never called, cmd_pending stays set and
cmd_work is never rescheduled.  As a result:

- a synchronous caller sleeps forever in pn533_send_cmd_sync()'s
  wait_for_completion();
- an asynchronous caller is never completed, leaking its callback
  context (e.g. struct pn533_data_exchange_arg, and the sock_hold()
  reference for rawsock);
- cmd_pending stuck at 1 makes every later command queue up without
  ever being sent, freezing the device until unbind.

The broken error path is as old as the command queue, but it used to
require an URB submission error to trigger; a device that stalls the
OUT endpoint reaches it via the send timeout added by the next patch.

Call the command's completion callback with the error and reschedule
cmd_work (unless the callback chained a direct command by returning
-EINPROGRESS) so that every queued command completes with an error and
the queue drains instead of freezing.

Signed-off-by: Zhao Feng <zhaofeng2@cmss.chinamobile.com>
Cc: <stable@vger.kernel.org>
---
 drivers/nfc/pn533/pn533.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/drivers/nfc/pn533/pn533.c b/drivers/nfc/pn533/pn533.c
index e2bc67300a..3087f4f347 100644
--- a/drivers/nfc/pn533/pn533.c
+++ b/drivers/nfc/pn533/pn533.c
@@ -572,9 +572,15 @@ static void pn533_wq_cmd(struct work_struct *work)
 	dev->cmd = cmd;
 	rc = dev->phy_ops->send_frame(dev, cmd->req);
 	if (rc < 0) {
+		int cb_rc;
+
 		dev->cmd = NULL;
 		dev_kfree_skb(cmd->req);
+		cb_rc = cmd->complete_cb(dev, cmd->complete_cb_context,
+					 ERR_PTR(rc));
 		kfree(cmd);
+		if (cb_rc != -EINPROGRESS)
+			queue_work(dev->wq, &dev->cmd_work);
 		return;
 	}
 
-- 
2.39.2
Technical Details
Message-ID: <20261027070136.1339-2-zhaofeng2@cmss.chinamobile.com>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-352251-linux-kernel-netdev=dewy.ru
References: <20261027070136.1339-1-zhaofeng2@cmss.chinamobile.com>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-352251-linux-kernel-netdev=dewy.ru
From: zhaofeng2@cmss.chinamobile.com (Zhao Feng)
Newsgroups: linux.kernel.netdev
Subject: [PATCH v2 1/2] nfc: pn533: complete failed queued commands and keep queue moving
Date: Tue, 27 Oct 2026 15:01:34 +0800
Organization: Usenet Network
Message-ID: <20261027070136.1339-2-zhaofeng2@cmss.chinamobile.com>
References: <20261027070136.1339-1-zhaofeng2@cmss.chinamobile.com>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
	logging-data="1481712"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:NxJz/GgWYl3mRDYSbNgGDzs4J8c= sha256:M/6sltd5Ug816a9BxUL9wdgvPXEtUlopkgaEZOtjOX4=
	sha1:RLErK1X3MpPhk8Fc9s2OsoHIoyc= sha256:m7CqAaEt0nzw4+cwyxHyJwfl0mxUXPTLnX96n/qVCJM=
List-ID: <netdev.vger.kernel.org>
X-Mailpost-Empty-Hdrs: X-Spam-Level
X-Received: from localhost (localhost [127.0.0.1])
	by mail.dewy.ru (Postfix) with ESMTP id D030F125BDD; Tue, 27 Oct 2026 10:02:13 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -2.849
X-Spam-Status: No, score=-2.849 tagged_above=-9999 required=6.31
	tests=[DKIM_INVALID=0.1, DKIM_SIGNED=0.1,
	HEADER_FROM_DIFFERENT_DOMAINS=0.25, MAILING_LIST_MULTI=-1,
	RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001,
	URIBL_BLOCKED=0.001] autolearn=ham autolearn_force=no
X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=fail (1024-bit key)
	reason="fail (body has been altered)" header.d=cmss.chinamobile.com
X-Received: from mail.dewy.ru ([127.0.0.1])
	by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024)
	with ESMTP id yMszRhBlcXHs;
	Tue, 27 Oct 2026 10:02:09 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.232.135.74; helo=sto.lore.kernel.org; envelope-from=netdev+bounces-352251-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> 
X-Authentication-Results: OpenDMARC; dmarc=fail (p=none dis=none) header.from=cmss.chinamobile.com
X-Received: from sto.lore.kernel.org (sto.lore.kernel.org [172.232.135.74])
	by mail.dewy.ru (Postfix) with ESMTPS id A5A04125BDC; Tue, 27 Oct 2026 10:02:01 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
	by sto.lore.kernel.org (Postfix) with ESMTP id CA33C601E2D; Tue, 27 Oct 2026 07:01:44 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass;
	t=1793084502;
	b=mMkdjnYM8yvAgYE892en+cBd5PMADv7FChhJ7Yl7XYaJfiJqcxBVICXiMmcknOyKhAH2
	 /DG/pYyCqdRegvdr7pWJvXbNdESL03AU2/oaOv+T7eyFtmffDxCq95VQuWgSW72t7Uvs8
	 VO0rYDkwIjSqk1hAqRyQMATfXtOrH6AYkp2MC6NCH9qwg1/zE+8+dSjFG61Cv0L5dgjMW
	 l9tu3cLwMs4DJYDPXIvabuBKEvjU+KY+pNbMHDpmZfigqF8yDOzj8DrUzW6hHag/FKmqj
	 3czyRaifp1IouFayPpPqo4grUNkr/0dDYUoQKlD3gIXbPa3sOdrGotvxFvVeJm/RbFQ==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1793084502;
	h=X-Original-To:Received:DMARC-Filter:DKIM-Signature:X-RM-TagInfo:
	 X-RM-SPAM-FLAG:Received:X-RM-TRANSID:X-RM-TagInfo:X-RM-SPAM-FLAG:
	 Received:X-RM-TRANSID:From:To:Cc:Subject:Date:Message-ID:X-Mailer:
	 In-Reply-To:References:X-Mailing-List:List-Id:List-Post:List-Help:
	 List-Subscribe:List-Unsubscribe:List-Owner:Precedence:MIME-Version:
	 Content-Transfer-Encoding;
	bh=5IU7roZYPT73HzaRWYumfNShgGxpbg+rxFWDb1S+Yao=;
	b=n9a8KWV26sCoc7gHTZ7MiG9sEndtz/OlSVFemQI+4FSAoCXXa0+JvLm1zQBAoU3JDfvd
	 ALACYYvkKeTWy5HA0ELrfdZa9PtS980Zjw2PcJ4GL5FGuVWLxgNTX8RdzN811VtnWH3k5
	 hBqaQSrNxNp50UH/cofvSzXyGWf+HSBTNfhz2XMSzVHDdtdTI1XbrKUpF+PWcHUEOx42+
	 jKAeloK6SugT5Ih6QYSDH+hlq0vmYE8jOuffYT1MpVBI+k8ckWTPSPQ0GR+5kMT11ZXOw
	 AgQNScp/k8+pwoMYaLWMUCcdRkl3tJaD0kVUDh5mChhuron2LedzeAE2o38ePlaxwVA==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; 
	dkim=pass header.d=cmss.chinamobile.com header.i=@cmss.chinamobile.com header.a=rsa-sha256 header.s=default header.b=HIYB2zSl;
	dmarc=pass header.from=cmss.chinamobile.com;
	spf=pass smtp.mailfrom=cmss.chinamobile.com;
	arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-Received: from localhost.localdomain (localhost [127.0.0.1])
	by smtp.subspace.kernel.org (Postfix) with ESMTP id ADDBD606A329;
	Tue, 27 Oct 2026 07:01:42 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
	dkim=pass (1024-bit key, unprotected) header.d=cmss.chinamobile.com header.i=@cmss.chinamobile.com header.a=rsa-sha256 header.s=default header.b=HIYB2zSl
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=111.22.67.151
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
	t=1793084501;
	b=P8asLJLjzsVIKMVIq9xAKd33vEmbSYPdOFq0V2acaQeBsMVEj6W0zEeJwYPj4pvnkf5z
	 hSgLiUmS5ggwiOgONW+JAhsYzJ+/WyDjgSdY8TzQUWVPWt8xyryeMH6KnzKNpUJhAOaBi
	 TvcxhLgJz7+m/2ed+UYPmi2FC7Hf8CZD7z3jnQjIu5wK79hStk5aJ2pGV5DmckYcVbuPr
	 UIuv9Zepm313B7XTyPt48f4FXXZ4sq1LPT9QGsk1PzzY+3X/gmNtZTWEpGuFKyZb/TAQB
	 qzCdsJICnBZkKw2YOI6MLwoJOHCQbmeH/r8E6I0qcsnJuIM/dKXTIrVOvXunMTrwdPg==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1793084501;
	h=DMARC-Filter:DKIM-Signature:X-RM-TagInfo:X-RM-SPAM-FLAG:Received:
	 X-RM-TRANSID:X-RM-TagInfo:X-RM-SPAM-FLAG:Received:X-RM-TRANSID:From:
	 To:Cc:Subject:Date:Message-ID:X-Mailer:In-Reply-To:References:
	 MIME-Version:Content-Transfer-Encoding;
	bh=5IU7roZYPT73HzaRWYumfNShgGxpbg+rxFWDb1S+Yao=;
	b=rLlnogRSx03+TDo3kZx6OEcZrHd6SjuFTdeJNtNilvQ7TMBELxpmNaJWptdwfdmv65J0
	 b+UTpMrJi9V0384zBaSAuniPFlFW6b1/XMnj51rJjKUU9s1zxKDKD+90L1KEwnduxBVmM
	 YqKrpeJP6ZH3yqVnefIeq71F+mbDMc7saVHXW7/dsVIfBPfzsNJWbre64MX6GmMCg0hvW
	 F0fKk562iZK/sG24mE5N0m5W+CBsDPG15mmtlHvnDethPvaQs5ejQIAmWvOPLfOYtZX7O
	 x5VxU3iIghpiagBGPVatrt7NKOz3VT6u/57fSDMFwqCY2mDP3KgCiFp8Kb+eZruGxMw==
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; 
	dmarc=pass header.from=cmss.chinamobile.com;
	spf=pass smtp.mailfrom=cmss.chinamobile.com;
	dkim=pass header.d=cmss.chinamobile.com header.i=@cmss.chinamobile.com header.a=rsa-sha256 header.s=default header.b=HIYB2zSl;
	arc=none smtp.remote-ip=111.22.67.151
X-Received: from cmccmta8.chinamobile.com (cmccmta8.chinamobile.com [111.22.67.151])
	by smtp.subspace.kernel.org (Postfix) with ESMTP id D2515606A328;
	Tue, 27 Oct 2026 07:01:39 +0000 (UTC)
X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org D2515606A328
X-Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=cmss.chinamobile.com
X-Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=cmss.chinamobile.com
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
	d=cmss.chinamobile.com; s=default; l=0;
	h=from:subject:message-id:to:cc:mime-version;
	bh=47DEQpj8HBSa+/TImW+5JCeuQeRkm5NMpJWZG3hSuFU=;
	b=HIYB2zSlW/XIaO+X/UKH8FB9q7NjFUCOMkWWhtlqd699eQoQ7SYlw5Eh8q518zG07EW+PcGa0JZAe
	 ZbQbW0Xu1JKoZgBCEtRZYezIB6ZAVgZgE+GfdQvOpyXAWlCCzE83cFe3V3IE2sFbLlonm31Ax4ArHR
	 98ns5gNCNC2iIYUc=
X-RM-TagInfo: emlType=0                                       
X-RM-SPAM-FLAG: 00000000
X-Received: from spf.mail.chinamobile.com (unknown[10.188.0.87])
	by rmmx-syy-dmz-app06-12006 (RichMail) with SMTP id 2ee66ae04c52dca-21fbf;
	Tue, 27 Oct 2026 15:01:38 +0800 (CST)
X-RM-TRANSID: 2ee66ae04c52dca-21fbf
X-RM-TagInfo: emlType=0                                       
X-RM-SPAM-FLAG: 00000000
X-Received: from  (unknown[10.55.1.71])
	by rmsmtp-syy-appsvr06-12006 (RichMail) with SMTP id 2ee66ae04c509fb-d0e58;
	Tue, 27 Oct 2026 15:01:38 +0800 (CST)
X-RM-TRANSID: 2ee66ae04c509fb-d0e58
X-Cc: krzysztof.kozlowski@linaro.org,
	linux-kernel@vger.kernel.org,
	syzbot+1c5368988052dc2d8201@syzkaller.appspotmail.com,
	Zhao Feng <zhaofeng2@cmss.chinamobile.com>,
	stable@vger.kernel.org
X-Mailer: git-send-email 2.55.0.windows.5
X-In-Reply-To: <20261027070136.1339-1-zhaofeng2@cmss.chinamobile.com>
X-Mailing-List: netdev@vger.kernel.org
X-List-Post: <mailto:netdev@vger.kernel.org>
X-List-Help: <mailto:netdev+help@vger.kernel.org>
X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org>
X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org>
X-List-Owner: <mailto:netdev+owner@vger.kernel.org>
X-Precedence: list