All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Hendrik Noack" <hendrik-noack@gmx.de>
Cc: robh@kernel.org, conor+dt@kernel.org, devicetree@vger.kernel.org,
	dmitry.torokhov@gmail.com, linux-input@vger.kernel.org
Subject: Re: [PATCH v8 2/2] Input: Add support for Wacom W9000-series penabled touchscreens
Date: Thu, 28 May 2026 09:01:22 +0000	[thread overview]
Message-ID: <20260528090123.554521F00A3A@smtp.kernel.org> (raw)
In-Reply-To: <20260528074818.12151-3-hendrik-noack@gmx.de>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] The driver uses stack-allocated buffers for I2C transfers, which violates the DMA API and can cause panics or memory corruption.
--

commit 5c60cba7d031762dd1ed0e3769ce031bf93c9b48
Author: Hendrik Noack <hendrik-noack@gmx.de>

Input: Add support for Wacom W9000-series penabled touchscreens

This commit adds a new input driver for the Wacom W9000-series penabled
touchscreens, supporting passive Wacom pens over an I2C interface.

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

[ ... ]

> +static int wacom_w9000_read(struct i2c_client *client, u8 command, u8 len, u8 *data)
> +{
> +	int error, res;
> +	struct i2c_msg msg[] = {
> +		{
> +			.addr = client->addr,
> +			.flags = 0,
> +			.buf = &command,
> +			.len = sizeof(command),

[Severity: High]
Is it safe to pass a stack-allocated variable (&command) as an I2C transfer
buffer? 

If the underlying I2C adapter uses DMA, transferring from a stack address
can lead to kernel panics or silent memory corruption. This happens because
stack memory is often virtually mapped (when CONFIG_VMAP_STACK is enabled)
and is not guaranteed to be safely cacheline aligned.

Would it be better to allocate these buffers dynamically or embed a 
DMA-safe buffer inside the wacom_w9000_data structure?

> +		}, {
> +			.addr = client->addr,
> +			.flags = I2C_M_RD,
> +			.buf = data,
> +			.len = len,
> +		}
> +	};
> +
> +	res = i2c_transfer(client->adapter, msg, ARRAY_SIZE(msg));
> +	if (res != ARRAY_SIZE(msg)) {
> +		error = res < 0 ? res : -EIO;
> +		dev_err(&client->dev, "%s: i2c transfer failed: %d (%d)\n", __func__, error, res);
> +		return error;
> +	}
> +
> +	return 0;
> +}
> +
> +static int wacom_w9000_query(struct wacom_w9000_data *wacom_data)
> +{
> +	struct i2c_client *client = wacom_data->client;
> +	struct device *dev = &wacom_data->client->dev;
> +	int error;
> +	int retry = 0;
> +	u8 data[CMD_QUERY_NUM_MAX];

[Severity: High]
Similarly, does passing this stack-allocated array down to wacom_w9000_read()
violate the DMA API requirements for the same reasons?

> +
> +	for (; retry < CMD_QUERY_RETRIES; retry++) {
> +		error = wacom_w9000_read(client, CMD_QUERY, wacom_data->variant->cmd_query_num,
> +					 data);

[ ... ]

> +static void wacom_w9000_coord(struct wacom_w9000_data *wacom_data)
> +{
> +	struct i2c_client *client = wacom_data->client;
> +	struct device *dev = &wacom_data->client->dev;
> +	int error;
> +	u8 data[MSG_COORD_NUM_MAX];
> +	bool touch, rubber, side_button;
> +	u16 x, y, pressure;
> +	u8 distance = 0;
> +
> +	error = i2c_master_recv(client, data, wacom_data->variant->msg_coord_num);

[Severity: High]
Can this call to i2c_master_recv() corrupt memory by DMAing into the
stack-allocated data array? Using a dedicated buffer allocated with kzalloc
or similar might prevent this issue on the coordinate data path.

> +	if (error != wacom_data->variant->msg_coord_num) {
> +		if (error >= 0)
> +			error = -EIO;

[ ... ]

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260528074818.12151-1-hendrik-noack@gmx.de?part=2

  reply	other threads:[~2026-05-28  9:01 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-28  7:48 [PATCH v8 0/2] Add support for Wacom W9000-series penabled touchscreens Hendrik Noack
2026-05-28  7:48 ` [PATCH v8 1/2] dt-bindings: Input: Add " Hendrik Noack
2026-05-28  8:32   ` sashiko-bot
2026-05-28 17:10     ` Conor Dooley
2026-05-28  7:48 ` [PATCH v8 2/2] Input: Add support for " Hendrik Noack
2026-05-28  9:01   ` sashiko-bot [this message]
2026-05-29  5:42   ` Dmitry Torokhov

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=20260528090123.554521F00A3A@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=dmitry.torokhov@gmail.com \
    --cc=hendrik-noack@gmx.de \
    --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 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.