Devicetree
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Muhammad Abu Bakar" <m.abubakar365@yahoo.com>
Cc: robh@kernel.org, conor+dt@kernel.org, devicetree@vger.kernel.org
Subject: Re: [PATCH 2/2] iio: pressure: add Sensirion SDP31 driver
Date: Sat, 19 Sep 2026 23:00:21 +0000	[thread overview]
Message-ID: <20260919230021.B39CE1F000FF@smtp.kernel.org> (raw)
In-Reply-To: <20260919223854.13437-3-m.abubakar365@yahoo.com>

Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [High] iio: pressure: data race on global sdp31_crc8_table during concurrent probes
- [Low] i2c: sdp31_id array uses positional instead of named initializers
--

commit 64f407e74ab363c060c44155c0fe0d881043f834
Author: Muhammad Abu Bakar <m.abubakar365@yahoo.com>

    iio: pressure: add Sensirion SDP31 driver
    
    Add an IIO driver for the Sensirion SDP31 differential pressure sensor.
    The device is accessed over I2C and reports differential pressure and
    temperature. Each measurement is validated using the sensor's CRC-8
    checksum.

> diff --git a/drivers/iio/pressure/sdp31.c b/drivers/iio/pressure/sdp31.c
> new file mode 100644
> index 0000000000000..934a3afcde7f3
> --- /dev/null
> +++ b/drivers/iio/pressure/sdp31.c
[ ... ]
> +DECLARE_CRC8_TABLE(sdp31_crc8_table);
[ ... ]
> +static int sdp31_check_crc(const u8 *word)
> +{
> +	if (crc8(sdp31_crc8_table, word, 2, SDP31_CRC8_INIT) != word[2])
> +		return -EIO;
> +	return 0;
> +}
[ ... ]
> +static int sdp31_probe(struct i2c_client *client)
> +{
> +	struct iio_dev *indio_dev;
> +	struct sdp31_data *data;
> +	struct sdp31_reading r;
> +	int ret;
> +
> +	indio_dev = devm_iio_device_alloc(&client->dev, sizeof(*data));
> +	if (!indio_dev)
> +		return -ENOMEM;
> +
> +	data = iio_priv(indio_dev);
> +	data->client = client;
> +	mutex_init(&data->lock);
> +
> +	crc8_populate_msb(sdp31_crc8_table, SDP31_CRC8_POLY);

[Severity: High]
Is it possible for this crc8_populate_msb() call to race with concurrent reads
of the same table?

DECLARE_CRC8_TABLE(sdp31_crc8_table) creates a global static array. If one
SDP31 device is actively queried from userspace, it reads from
sdp31_crc8_table in sdp31_check_crc().

If a second SDP31 device is probed simultaneously (for example, via a bus
rescan or hotplug event), sdp31_probe() will unconditionally write to this
global array without synchronization.

Could this initialization be protected with something like DO_ONCE(), or moved
to the module initialization phase?

[ ... ]
> +static const struct i2c_device_id sdp31_id[] = {
> +	{ "sdp31" },

[Severity: Low]
Should this array use named initializers to align with I2C subsystem
guidelines?

The I2C subsystem requires arrays of type struct i2c_device_id to explicitly
use named initializers.

Could this be updated to use explicit initialization, such as
{ .name = "sdp31" }?

> +	{ }
> +};
> +MODULE_DEVICE_TABLE(i2c, sdp31_id);

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260919223854.13437-1-m.abubakar365@yahoo.com?part=2

  reply	other threads:[~2026-09-19 23:00 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20260919223854.13437-1-m.abubakar365.ref@yahoo.com>
2026-09-19 22:38 ` [PATCH 0/2] iio: pressure: add Sensirion SDP31 driver Muhammad Abu Bakar
2026-09-19 22:38   ` [PATCH 1/2] dt-bindings: iio: pressure: add Sensirion SDP31 Muhammad Abu Bakar
2026-09-19 22:55     ` sashiko-bot
2026-09-20  0:40     ` Jonathan Cameron
2026-09-28 20:45       ` Muhammad Abu Bakar
2026-09-19 22:38   ` [PATCH 2/2] iio: pressure: add Sensirion SDP31 driver Muhammad Abu Bakar
2026-09-19 23:00     ` sashiko-bot [this message]
2026-09-20  0:53     ` Jonathan Cameron
2026-09-20  0:34   ` [PATCH 0/2] " Jonathan Cameron

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=20260919230021.B39CE1F000FF@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=m.abubakar365@yahoo.com \
    --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