Devicetree
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Qianhui Xu" <xiaqinghuan@mail.ustc.edu.cn>
Cc: linux-input@vger.kernel.org, devicetree@vger.kernel.org,
	robh@kernel.org, conor+dt@kernel.org, dmitry.torokhov@gmail.com
Subject: Re: [PATCH v4 3/7] Input: novatek-nvt-ts - add SPI bus support
Date: Wed, 02 Dec 2026 06:21:33 +0000	[thread overview]
Message-ID: <sashiko-outbox-244955@kernel.org> (raw)
In-Reply-To: <20261202061414.548247-3-xiaqinghuan@mail.ustc.edu.cn>

Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Low] Input: novatek-nvt-ts - open-coded kzalloc() and kfree() in
  nvt_ts_spi_read()
--

commit 5f4104996cb50a4abaced3ceff54734af0768c3b
Author: Qianhui Xu <xiaqinghuan@mail.ustc.edu.cn>

Input: novatek-nvt-ts - add SPI bus support

This commit adds an SPI driver for Novatek NVT touchscreen controllers and
builds the shared core as a separate Kconfig symbol.

> diff --git a/drivers/input/touchscreen/novatek-nvt-ts-spi.c b/drivers/input/touchscreen/novatek-nvt-ts-spi.c
> new file mode 100644
> index 0000000000000..8840e764623d3
> --- /dev/null
> +++ b/drivers/input/touchscreen/novatek-nvt-ts-spi.c
> @@ -0,0 +1,103 @@

[ ... ]

> +static int nvt_ts_spi_read(struct nvt_ts_data *data, u8 reg, u8 *buf,
> +			   size_t count)
> +{
> +	struct spi_device *spi = to_spi_device(data->dev);
> +	struct spi_transfer xfer = { };
> +	u8 *tx, *rx;
> +	int error;
> +
> +	/*
> +	 * The read has to be one full-duplex transfer: the address byte and one
> +	 * dummy byte go out while the payload comes in.  Split into a write and
> +	 * a read transfer the controller hands back the bytes it was sent
> +	 * instead of the payload.
> +	 *
> +	 * Both buffers are mapped for DMA as is, so neither the caller's buffer
> +	 * nor a stack buffer can be used.
> +	 */
> +	tx = kmalloc(count + 2, GFP_KERNEL);
> +	rx = kmalloc(count + 2, GFP_KERNEL);
> +	if (!tx || !rx) {
> +		error = -ENOMEM;
> +		goto out;
> +	}
> +
> +	memset(tx, 0, count + 2);
> +	tx[0] = reg & 0x7f;
> +	xfer.tx_buf = tx;
> +	xfer.rx_buf = rx;
> +	xfer.len = count + 2;
> +
> +	error = spi_sync_transfer(spi, &xfer, 1);
> +	if (!error)
> +		memcpy(buf, rx + 2, count);
> +out:
> +	kfree(rx);
> +	kfree(tx);
> +
> +	return error;
> +}

[Severity: Low]
This isn't a bug, but could tx and rx use __free(kfree), with tx allocated
via kzalloc() instead of kmalloc() followed by memset()?  That would drop
the manual memset() and the out label.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261202061414.548247-1-xiaqinghuan@mail.ustc.edu.cn?part=3

  reply	other threads:[~2026-12-02  6:21 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-02  6:14 [PATCH v4 1/7] Input: novatek-nvt-ts - add transport ops abstraction Qianhui Xu
2026-12-02  6:14 ` [PATCH v4 2/7] Input: novatek-nvt-ts - split bus independent core out Qianhui Xu
2026-12-02  6:14 ` [PATCH v4 3/7] Input: novatek-nvt-ts - add SPI bus support Qianhui Xu
2026-12-02  6:21   ` sashiko-bot [this message]
2026-12-02  6:14 ` [PATCH v4 4/7] dt-bindings: input: novatek,nvt-ts - allow SPI wiring Qianhui Xu
2026-12-02  6:14 ` [PATCH v4 5/7] Input: novatek-nvt-ts - add NT36536 packet decoding Qianhui Xu
2026-12-02  6:14 ` [PATCH v4 6/7] dt-bindings: input: novatek,nvt-ts - add the NT36536 compatible Qianhui Xu
2026-12-02  6:14 ` [PATCH v4 7/7] Input: novatek-nvt-ts - add no-flash firmware download Qianhui Xu
2026-12-02  6:21   ` 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=sashiko-outbox-244955@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=dmitry.torokhov@gmail.com \
    --cc=linux-input@vger.kernel.org \
    --cc=robh@kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=xiaqinghuan@mail.ustc.edu.cn \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox