From: sashiko-bot@kernel.org
To: "Jorijn van der Graaf" <jorijnvdgraaf@catcrafts.net>
Cc: devicetree@vger.kernel.org, conor+dt@kernel.org, robh@kernel.org
Subject: Re: [PATCH v5 5/6] nfc: s3fwrn5: support the S3NRN4V variant
Date: Wed, 12 Aug 2026 22:15:03 +0000 [thread overview]
Message-ID: <20260812221503.9AAF61F00A3D@smtp.kernel.org> (raw)
In-Reply-To: <20260811220135.472380-6-jorijnvdgraaf@catcrafts.net>
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [High] Missing error check on nci_prop_cmd() for GET_VER causes command-response desynchronization on timeouts.
- [High] Hardware error statuses are ignored because the driver checks for negative return values instead of non-zero.
--
--- Patch [5]: [PATCH v5 5/6] nfc: s3fwrn5: support the S3NRN4V variant ---
commit fe1c1a464a09b355d0a14c76e391f1834e4afedf
Author: Jorijn van der Graaf <jorijnvdgraaf@catcrafts.net>
nfc: s3fwrn5: support the S3NRN4V variant
Adds support for the Samsung S3NRN4V NFC controller, which requires a new
calibration data bring-up sequence and different clock speed configuration.
> diff --git a/drivers/nfc/s3fwrn5/nci.c b/drivers/nfc/s3fwrn5/nci.c
> --- a/drivers/nfc/s3fwrn5/nci.c
> +++ b/drivers/nfc/s3fwrn5/nci.c
[ ... ]
> +int s3fwrn5_nci_rf_configure_dual(struct s3fwrn5_info *info,
> + const char *hw_name, const char *sw_name)
> +{
[ ... ]
> + /*
> + * Ask the chip for its current calibration versions and skip the
> + * upload when both already match the blobs; a mismatch or an
> + * unparseable answer means the upload proceeds. GET_VER answers with
> + * versions, not a status byte, so nci_prop_cmd()'s return carries no
> + * meaning here.
> + */
> + sub_oid = NCI_PROP_DUAL_SUB_GET_VER;
> + info->dual_rsp_len = 0;
> + nci_prop_cmd(info->ndev, NCI_PROP_DUAL_OPTION, 1, &sub_oid);
> + if (s3fwrn5_nci_dual_cal_current(info, hw_fw, sw_fw)) {
[Severity: High]
Is it safe to completely ignore the return value of nci_prop_cmd() here?
If the hardware is slow to respond to the initial GET_VER command,
nci_prop_cmd() will return -ETIMEDOUT. Continuing directly to START_UPDATE
without checking for this timeout might cause command-response
desynchronization.
A late response to the timed-out GET_VER command could arrive while waiting
for the START_UPDATE response, which might silently corrupt the sequence
since all DUAL_OPTION sub-commands share the same NCI opcode.
> + dev_dbg(dev, "calibration data already current\n");
> + ret = 0;
> + goto out_sw;
> + }
> +
> + merged = kvmalloc(merged_size, GFP_KERNEL);
> + if (!merged) {
[ ... ]
> + /* SET_OPTION per section */
> + set_option.sub_oid = NCI_PROP_DUAL_SUB_SET_OPTION;
> + set_option.index = 0;
> + for (i = 0; i < merged_size; i += NCI_PROP_DUAL_SECTION_SIZE) {
> + len = min_t(size_t, merged_size - i, NCI_PROP_DUAL_SECTION_SIZE);
> + memcpy(set_option.data, merged + i, len);
> + ret = nci_prop_cmd(info->ndev, NCI_PROP_DUAL_OPTION,
> + len + 2, (__u8 *)&set_option);
> + if (ret < 0) {
[Severity: High]
Does this check miss positive hardware error statuses?
When the chip rejects a command, it returns a positive NCI status byte
(like NCI_STATUS_REJECTED, 0x09). The driver's RX handler passes this status
to nci_req_complete(), which sets req_result. nci_prop_cmd() then returns
this positive integer.
Checking only for ret < 0 might cause the driver to ignore hardware
rejections and erroneously consider the upload chunks successful. Should this
check for ret != 0 instead?
> + dev_err(dev, "calibration data update error: %d\n",
> + ret);
> + /* Abort form: STOP_UPDATE with the sub-OID alone. */
> + sub_oid = NCI_PROP_DUAL_SUB_STOP_UPDATE;
> + nci_prop_cmd(info->ndev, NCI_PROP_DUAL_OPTION, 1,
> + &sub_oid);
> + goto out;
> + }
> + set_option.index++;
> + }
> +
> + /* STOP_UPDATE with checksum */
> + stop_cmd[0] = NCI_PROP_DUAL_SUB_STOP_UPDATE;
> + put_unaligned_le16(checksum, &stop_cmd[1]);
> + ret = nci_prop_cmd(info->ndev, NCI_PROP_DUAL_OPTION, 3, stop_cmd);
> + if (ret < 0) {
[Severity: High]
Similarly, would a positive error status from the hardware on STOP_UPDATE be
missed here due to the ret < 0 check?
> + dev_err(dev, "Unable to stop calibration data update\n");
> + goto out;
> + }
> +
> + dev_dbg(dev, "calibration data update: success\n");
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260811220135.472380-1-jorijnvdgraaf@catcrafts.net?part=5
next prev parent reply other threads:[~2026-08-12 22:15 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-11 22:01 [PATCH v5 0/6] nfc: s3fwrn5: support the S3NRN4V variant Jorijn van der Graaf
2026-08-11 22:01 ` [PATCH v5 1/6] nfc: s3fwrn5: drop of_match_ptr() from the I2C driver Jorijn van der Graaf
2026-08-12 22:15 ` sashiko-bot
2026-08-11 22:01 ` [PATCH v5 2/6] nfc: s3fwrn5: use the "s3fwrn5_i2c" string literal directly Jorijn van der Graaf
2026-08-11 22:01 ` [PATCH v5 3/6] dt-bindings: net: nfc: samsung,s3fwrn5: add the S3NRN4V Jorijn van der Graaf
2026-08-11 22:01 ` [PATCH v5 4/6] nfc: s3fwrn5: enable the PVDD supply Jorijn van der Graaf
2026-08-11 22:01 ` [PATCH v5 5/6] nfc: s3fwrn5: support the S3NRN4V variant Jorijn van der Graaf
2026-08-12 11:18 ` David Heidelberg
2026-08-12 15:28 ` Jorijn van der Graaf
2026-08-12 22:15 ` sashiko-bot [this message]
2026-08-11 22:01 ` [PATCH v5 6/6] arm64: dts: qcom: milos-fairphone-fp6: Add NFC Jorijn van der Graaf
2026-08-12 22:15 ` sashiko-bot
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260812221503.9AAF61F00A3D@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=jorijnvdgraaf@catcrafts.net \
--cc=robh@kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.