Devicetree
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Lukas Timmermann" <foss@timmermann.space>
Cc: conor+dt@kernel.org, devicetree@vger.kernel.org,
	dmitry.torokhov@gmail.com, robh@kernel.org,
	linux-input@vger.kernel.org
Subject: Re: [PATCH 4/7] Input: s6sy761 - add SPI support for S6SY791
Date: Sun, 11 Oct 2026 13:02:30 +0000	[thread overview]
Message-ID: <sashiko-outbox-167242@kernel.org> (raw)
In-Reply-To: <20261011-lat3st-google-raven-touch-upstream-v1-4-2a9f55159b9e@timmermann.space>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] input: s6sy761: DMA API violation in i2c_transfer with stack buffers
--

commit 4918bc0af27755ebb84f3e96213a8de871d7f898
Author: Lukas Timmermann <foss@timmermann.space>

Input: s6sy761 - add SPI support for S6SY791

This commit adds SPI support for the S6SY791 touchscreen controller.
It implements the SPI framing and read delays based on the downstream driver.
The new functionality operates over full-duplex SPI with padded transfers.

> diff --git a/drivers/input/touchscreen/s6sy761_spi.c b/drivers/input/touchscreen/s6sy761_spi.c
> new file mode 100644
> index 0000000000000..c6627e61c2856
> --- /dev/null
> +++ b/drivers/input/touchscreen/s6sy761_spi.c

[ ... ]

> +static int s6sy761_spi_read(struct device *dev, u8 *xfer_buf,
> +			    u8 cmd, size_t length, void *values)
> +{
> +	struct spi_device *spi = to_spi_device(dev);
> +	struct spi_transfer reply = { };

[ ... ]

> +	ret = spi_sync_transfer(spi, &reply, 1);
> +	if (ret)
> +		return ret;
> +
> +	if (xfer_buf[0] != S6SY761_SPI_SYNC_CODE ||
> +	    xfer_buf[5] != cmd ||
> +	    xfer_buf[resp_len - 1] !=
> +			s6sy761_spi_checksum(xfer_buf, resp_len - 1))
> +		return -EIO;
> +
> +	memcpy(values, xfer_buf + S6SY761_SPI_READ_HEADER_SIZE, length);
> +
> +	return 0;
> +}

[Severity: High]
While the SPI implementation safely copies the response into the values buffer
using memcpy, does the I2C implementation violate DMA safety requirements
by passing this buffer directly into i2c_transfer?

Looking at drivers/input/touchscreen/s6sy761_core.c:s6sy761_power_on(),
it allocates a small buffer on the stack and passes it down to the bus read
routine:

    u8 buffer[S6SY761_EVENT_SIZE];
    ...
    ret = s6sy761_read(sdata, S6SY761_READ_ONE_EVENT, S6SY761_EVENT_SIZE, buffer);

This calls s6sy761_i2c_read() in drivers/input/touchscreen/s6sy761_i2c.c,
which assigns both the caller's stack pointer (values) and its own local
stack variable (&cmd) directly to struct i2c_msg buffers:

	struct i2c_msg msgs[2] = {
		{
			.addr	= client->addr,
			.len	= 1,
			.buf	= &cmd,
		},
		{
			.addr	= client->addr,
			.flags	= I2C_M_RD,
			.len	= length,
			.buf	= values,
		},
	};
	int ret;

	ret = i2c_transfer(client->adapter, msgs, ARRAY_SIZE(msgs));

It then calls i2c_transfer() which may use DMA. Stack memory is not DMA-safe
(especially with CONFIG_VMAP_STACK), leading to potential memory corruption or
kernel panics when DMA operates on stack addresses. Is it possible to use the
dynamically allocated xfer_buf for I2C transfers instead?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261011-lat3st-google-raven-touch-upstream-v1-0-2a9f55159b9e@timmermann.space?part=4

  reply	other threads:[~2026-10-11 13:02 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-11 12:44 [PATCH 0/7] Input: s6sy761 - add SPI support for the S6SY791 Lukas Timmermann
2026-10-11 12:44 ` [PATCH 1/7] dt-bindings: input: touchscreen: samsung,s6sy761: Add S6SY791 and reset GPIO Lukas Timmermann
2026-10-11 12:53   ` sashiko-bot
2026-10-12 11:30   ` Krzysztof Kozlowski
2026-10-11 12:44 ` [PATCH 2/7] Input: s6sy761 - split into core and I2C modules Lukas Timmermann
2026-10-11 12:57   ` sashiko-bot
2026-10-12 11:04   ` Uwe Kleine-König
2026-10-11 12:44 ` [PATCH 3/7] Input: s6sy761 - add reset GPIO support Lukas Timmermann
2026-10-11 12:58   ` sashiko-bot
2026-10-11 12:44 ` [PATCH 4/7] Input: s6sy761 - add SPI support for S6SY791 Lukas Timmermann
2026-10-11 13:02   ` sashiko-bot [this message]
2026-10-11 12:45 ` [PATCH 5/7] arm64: dts: exynos: gs101-pixel-common: add labels for touchscreen supplies Lukas Timmermann
2026-10-11 12:45 ` [PATCH 6/7] arm64: dts: exynos: gs101-raven: add S6SY791 touchscreen Lukas Timmermann
2026-10-11 12:45 ` [PATCH 7/7] MAINTAINERS: add entry for Samsung S6SY761 touchscreen driver Lukas Timmermann

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-167242@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=dmitry.torokhov@gmail.com \
    --cc=foss@timmermann.space \
    --cc=linux-input@vger.kernel.org \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox