Linux Hardware Monitor development
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Svyatoslav Ryhel" <clamor95@gmail.com>
Cc: conor+dt@kernel.org, robh@kernel.org,
	linux-hwmon@vger.kernel.org, devicetree@vger.kernel.org
Subject: Re: [PATCH v2 2/3] hwmon: (emc1403) Convert to use OF bindings
Date: Fri, 19 Jun 2026 10:45:46 +0000	[thread overview]
Message-ID: <20260619104546.CDEA01F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260619103153.216444-3-clamor95@gmail.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] Ambiguous OF match data value (0) prevents error handling for unsupported devices.
--

commit 7ef40c1ea161b005037b0b33a8e16b1f9bf6d41a
Author: Jonas Schwöbel <jonasschwoebel@yahoo.de>

hwmon: (emc1403) Convert to use OF bindings

This commit adds an OF match compatible table to the emc1403 driver
to enable device tree support.

> --- a/drivers/hwmon/emc1403.c
> +++ b/drivers/hwmon/emc1403.c
[ ... ]
> @@ -659,14 +660,14 @@ static int emc1403_probe(struct i2c_client *client)
[ ... ]
> -	data->chip = id->driver_data;
> +	data->chip = (uintptr_t)i2c_get_match_data(client);
> +

[Severity: Medium]
Will this cast silently hide error conditions?

If an unsupported device is manually bound via sysfs, i2c_get_match_data()
will return NULL (no match found). Since emc1402 evaluates to 0 in the
emc1403_chip enum, casting NULL to uintptr_t assigns 0 to data->chip. This
causes the driver to proceed as if an emc1402 device was found, rather than
safely aborting and returning -ENODEV.

[ ... ]
> @@ -682,10 +683,21 @@ static const unsigned short emc1403_address_list[] = {
[ ... ]
> +static const struct of_device_id emc1403_of_match[] = {
> +	{ .compatible = "smsc,emc1402", .data = (void *)emc1402 },
> +	{ .compatible = "smsc,emc1403", .data = (void *)emc1403 },

[Severity: Medium]
Does assigning 0 as the match data here cause ambiguity during device matching?

Because emc1402 is 0, when device_get_match_data() matches "smsc,emc1402",
it returns NULL. This forces i2c_get_match_data() to fall back to
i2c_match_id().

While this happens to succeed for valid DT nodes because the I2C core strips
the vendor prefix (allowing the id_table to match), it removes the ability
to distinguish between a successful emc1402 match and an error where no
match was found at all.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260619103153.216444-1-clamor95@gmail.com?part=2

  reply	other threads:[~2026-06-19 10:45 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-19 10:31 [PATCH v2 0/3] hwmon: emc1403: Convert to use OF bindings and add regulator support Svyatoslav Ryhel
2026-06-19 10:31 ` [PATCH v2 1/3] dt-bindings: hwmon: Document SMSC EMC1402/1403/1404/1428 Svyatoslav Ryhel
2026-06-19 10:40   ` sashiko-bot
2026-06-19 10:31 ` [PATCH v2 2/3] hwmon: (emc1403) Convert to use OF bindings Svyatoslav Ryhel
2026-06-19 10:45   ` sashiko-bot [this message]
2026-06-19 10:31 ` [PATCH v2 3/3] hwmon: (emc1403) Add regulator support Svyatoslav Ryhel
2026-06-19 10:41   ` 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=20260619104546.CDEA01F000E9@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=clamor95@gmail.com \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=linux-hwmon@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