All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ivy Lopez <skunkolee@gmail.com>
To: marius.cristea@microchip.com, linux@roeck-us.net
Cc: linux-hwmon@vger.kernel.org, linux-kernel@vger.kernel.org,
	Ivy Lopez <skunkolee@gmail.com>
Subject: [PATCH] hwmon: emc1812: reject channel index 0 in device tree config
Date: Wed, 15 Jul 2026 18:25:43 -0600	[thread overview]
Message-ID: <20260716002543.26711-1-skunkolee@gmail.com> (raw)

Channel index 0 is reserved for the internal diode and is set
unconditionally before parsing child nodes. If a child node specifies
reg = 0, it silently overwrites the internal diode label

Reject reg = 0 in child nodes and improve the error message to
include the invalid index value.

Signed-off-by: Ivy Lopez <skunkolee@gmail.com>
---
 drivers/hwmon/emc1812.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/hwmon/emc1812.c b/drivers/hwmon/emc1812.c
index 68575c27d090..143c3c07dbaa 100644
--- a/drivers/hwmon/emc1812.c
+++ b/drivers/hwmon/emc1812.c
@@ -809,9 +809,10 @@ static int emc1812_parse_fw_config(struct emc1812_data *data, struct device *dev
 
 	device_for_each_child_node_scoped(dev, child) {
 		ret = fwnode_property_read_u32(child, "reg", &reg_nr);
-		if (ret || reg_nr >= data->chip->phys_channels)
+		if (ret || reg_nr == 0 || reg_nr >= data->chip->phys_channels)
 			return dev_err_probe(dev, -EINVAL,
-					     "The index is higher then the chip supports\n");
+					"Invalid channel index %u\n",
+					reg_nr);
 		/* Mark channel as active */
 		set_bit(reg_nr, &data->active_ch_mask);
 
-- 
2.55.0


             reply	other threads:[~2026-07-16  0:25 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-16  0:25 Ivy Lopez [this message]
2026-07-16  0:34 ` [PATCH] hwmon: emc1812: reject channel index 0 in device tree config Guenter Roeck
2026-07-16  0:37 ` 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=20260716002543.26711-1-skunkolee@gmail.com \
    --to=skunkolee@gmail.com \
    --cc=linux-hwmon@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@roeck-us.net \
    --cc=marius.cristea@microchip.com \
    /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.