Linux Input/HID development
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Lukas Timmermann" <foss@timmermann.space>
Cc: linux-input@vger.kernel.org, devicetree@vger.kernel.org,
	robh@kernel.org, conor+dt@kernel.org, dmitry.torokhov@gmail.com
Subject: Re: [PATCH v2 4/7] Input: s6sy761 - add SPI support for S6SY791
Date: Sat, 28 Nov 2026 14:03:11 +0000	[thread overview]
Message-ID: <sashiko-outbox-238744@kernel.org> (raw)
In-Reply-To: <20261128-lat3st-google-raven-touch-upstream-v2-4-1be5c1029087@timmermann.space>

Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [High] Input: s6sy761: DMA-unsafe stack buffers in s6sy761_i2c_read()
--

commit 41cdfc7d2236b662f8b09dd26455edb5cb7aa912
Author: Lukas Timmermann <foss@timmermann.space>

Input: s6sy761 - add SPI support for S6SY791

This commit adds an SPI transport module for the Samsung S6SY791 touchscreen
controller using the shared s6sy761 core driver.

> diff --git a/drivers/input/touchscreen/s6sy761_spi.c b/drivers/input/touchscreen/s6sy761_spi.c
> new file mode 100644
> index 0000000000000..ddb849cd48457
> --- /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)
> +{
[ ... ]
> +	memset(xfer_buf, 0, ALIGN(resp_len, 4));
> +	reply.tx_buf = xfer_buf;
> +	reply.rx_buf = xfer_buf;
> +	reply.len = ALIGN(resp_len, 4);
> +	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 s6sy761_spi_read() bounces transfers through the heap-allocated
xfer_buf, does s6sy761_i2c_read() in commit "Input: s6sy761 - split into
core and I2C modules" pass stack buffers directly to i2c_transfer()?

drivers/input/touchscreen/s6sy761_i2c.c:s6sy761_i2c_read() {
	struct i2c_client *client = to_i2c_client(dev);
	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));
    ...
}

msgs[0].buf points to the stack parameter cmd, and callers such as
s6sy761_power_on() and s6sy761_hw_init() also pass stack buffers as values.
Because I2C controllers may DMA directly from and into i2c_msg buffers,
passing stack addresses under CONFIG_VMAP_STACK can fail DMA mapping or
corrupt memory.  Should s6sy761_i2c_read() use xfer_buf for both messages
and copy the result into values?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261128-lat3st-google-raven-touch-upstream-v2-0-1be5c1029087@timmermann.space?part=4

  reply	other threads:[~2026-11-28 14:03 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-28 13:51 [PATCH v2 0/7] Input: s6sy761 - add SPI support for the S6SY791 Lukas Timmermann
2026-11-28 13:51 ` [PATCH v2 1/7] dt-bindings: input: touchscreen: samsung,s6sy761: Add S6SY791 and reset GPIO Lukas Timmermann
2026-11-28 13:51 ` [PATCH v2 2/7] Input: s6sy761 - split into core and I2C modules Lukas Timmermann
2026-11-28 13:51 ` [PATCH v2 3/7] Input: s6sy761 - add reset GPIO support Lukas Timmermann
2026-11-28 13:59   ` sashiko-bot
2026-11-28 13:51 ` [PATCH v2 4/7] Input: s6sy761 - add SPI support for S6SY791 Lukas Timmermann
2026-11-28 14:03   ` sashiko-bot [this message]
2026-11-28 13:51 ` [PATCH v2 5/7] arm64: dts: exynos: gs101-pixel-common: add labels for touchscreen supplies Lukas Timmermann
2026-11-28 13:51 ` [PATCH v2 6/7] arm64: dts: exynos: gs101-raven: add S6SY791 touchscreen Lukas Timmermann
2026-11-28 14:02   ` sashiko-bot
2026-11-28 13:51 ` [PATCH v2 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-238744@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