* [PATCH net-next] nfc: digital: Do not dump a NULL response in command completion
@ 2026-07-10 6:12 Linmao Li
2026-07-10 9:51 ` Przemek Kitszel
0 siblings, 1 reply; 2+ messages in thread
From: Linmao Li @ 2026-07-10 6:12 UTC (permalink / raw)
To: David Heidelberg, David S . Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni
Cc: Simon Horman, Mark Greer, netdev, oe-linux-nfc, linux-kernel,
Linmao Li
digital_wq_cmd_complete() dumps the response data whenever cmd->resp is
not an error pointer. However, a driver can legitimately complete a
command with no response skb at all.
digital_tg_send_psl_res() is the only caller that passes timeout=0,
meaning no response is expected once the command has been transmitted.
On that path trf7970a completes the command with
trf->rx_skb = ERR_PTR(0);
which evaluates to NULL. IS_ERR(NULL) is false, so the NULL response
passes the !IS_ERR() check and cmd->resp->data and cmd->resp->len are
dereferenced whenever the debug print site is enabled. The driver
guards its own dump with "trf->rx_skb && !IS_ERR(trf->rx_skb)"; the
digital layer is missing the NULL half of that test.
Use IS_ERR_OR_NULL() so that NULL responses are skipped as well. The
callback on that path, digital_tg_send_psl_res_complete(), never
dereferences resp and dev_kfree_skb() accepts NULL, so only the debug
dump needs fixing.
Fixes: 59ee2361c924 ("NFC Digital: Implement driver commands mechanism")
Signed-off-by: Linmao Li <lilinmao@kylinos.cn>
---
A separate cleanup patch, "nfc: trf7970a: Use NULL when no response is
expected", replaces that ERR_PTR(0) with a plain NULL. It does not
change behaviour (ERR_PTR(0) is NULL), so this fix is needed either way;
if that patch lands first, read "trf->rx_skb = NULL;" above.
Link: https://patch.msgid.link/20260706075743.564658-1-lilinmao@kylinos.cn
net/nfc/digital_core.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/net/nfc/digital_core.c b/net/nfc/digital_core.c
index 7cb1e6aaae90..18236221d898 100644
--- a/net/nfc/digital_core.c
+++ b/net/nfc/digital_core.c
@@ -127,7 +127,7 @@ static void digital_wq_cmd_complete(struct work_struct *work)
mutex_unlock(&ddev->cmd_lock);
- if (!IS_ERR(cmd->resp))
+ if (!IS_ERR_OR_NULL(cmd->resp))
print_hex_dump_debug("DIGITAL RX: ", DUMP_PREFIX_NONE, 16, 1,
cmd->resp->data, cmd->resp->len, false);
--
2.25.1
^ permalink raw reply related [flat|nested] 2+ messages in thread* Re: [PATCH net-next] nfc: digital: Do not dump a NULL response in command completion
2026-07-10 6:12 [PATCH net-next] nfc: digital: Do not dump a NULL response in command completion Linmao Li
@ 2026-07-10 9:51 ` Przemek Kitszel
0 siblings, 0 replies; 2+ messages in thread
From: Przemek Kitszel @ 2026-07-10 9:51 UTC (permalink / raw)
To: Linmao Li
Cc: Simon Horman, Mark Greer, netdev, oe-linux-nfc, linux-kernel,
David Heidelberg, David S . Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni
On 7/10/26 08:12, Linmao Li wrote:
> digital_wq_cmd_complete() dumps the response data whenever cmd->resp is
> not an error pointer. However, a driver can legitimately complete a
> command with no response skb at all.
>
> digital_tg_send_psl_res() is the only caller that passes timeout=0,
> meaning no response is expected once the command has been transmitted.
> On that path trf7970a completes the command with
>
> trf->rx_skb = ERR_PTR(0);
>
> which evaluates to NULL. IS_ERR(NULL) is false, so the NULL response
> passes the !IS_ERR() check and cmd->resp->data and cmd->resp->len are
> dereferenced whenever the debug print site is enabled. The driver
> guards its own dump with "trf->rx_skb && !IS_ERR(trf->rx_skb)"; the
> digital layer is missing the NULL half of that test.
>
> Use IS_ERR_OR_NULL() so that NULL responses are skipped as well. The
> callback on that path, digital_tg_send_psl_res_complete(), never
> dereferences resp and dev_kfree_skb() accepts NULL, so only the debug
> dump needs fixing.
>
> Fixes: 59ee2361c924 ("NFC Digital: Implement driver commands mechanism")
> Signed-off-by: Linmao Li <lilinmao@kylinos.cn>
Reviewed-by: Przemek Kitszel <przemyslaw.kitszel@intel.com>
> ---
> A separate cleanup patch, "nfc: trf7970a: Use NULL when no response is
> expected", replaces that ERR_PTR(0) with a plain NULL. It does not
> change behaviour (ERR_PTR(0) is NULL), so this fix is needed either way;
> if that patch lands first, read "trf->rx_skb = NULL;" above.
>
> Link: https://patch.msgid.link/20260706075743.564658-1-lilinmao@kylinos.cn
>
> net/nfc/digital_core.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/net/nfc/digital_core.c b/net/nfc/digital_core.c
> index 7cb1e6aaae90..18236221d898 100644
> --- a/net/nfc/digital_core.c
> +++ b/net/nfc/digital_core.c
> @@ -127,7 +127,7 @@ static void digital_wq_cmd_complete(struct work_struct *work)
>
> mutex_unlock(&ddev->cmd_lock);
>
> - if (!IS_ERR(cmd->resp))
> + if (!IS_ERR_OR_NULL(cmd->resp))
> print_hex_dump_debug("DIGITAL RX: ", DUMP_PREFIX_NONE, 16, 1,
> cmd->resp->data, cmd->resp->len, false);
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-07-10 9:52 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-10 6:12 [PATCH net-next] nfc: digital: Do not dump a NULL response in command completion Linmao Li
2026-07-10 9:51 ` Przemek Kitszel
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox