Thread (48 messages) 48 messages, 6 authors, 2026-01-29

Re: [PATCH v2 net-next 01/15] net: mdio-regmap: permit working with non-MMIO regmaps

From: Vladimir Oltean <vladimir.oltean@nxp.com>
Date: 2026-01-22 13:47:11
Also in: linux-devicetree, lkml
Subsystem: ethernet phy library, mdio regmap driver, networking drivers, the rest · Maintainers: Andrew Lunn, Heiner Kallweit, Maxime Chevallier, "David S. Miller", Eric Dumazet, Jakub Kicinski, Paolo Abeni, Linus Torvalds

On Thu, Jan 22, 2026 at 02:13:01PM +0200, Vladimir Oltean wrote:
quoted
quoted
 struct mdio_regmap_priv {
 	struct regmap *regmap;
+	unsigned int base;
Hmm... resource_size_t ?
Well, regmap_read() takes "unsigned int reg".
https://elixir.bootlin.com/linux/v6.18.6/source/include/linux/regmap.h#L1297
So in practice, a truncation will be done somewhere if the register base
exceeds unsigned int storage capacity. But I didn't feel that it's worth
handling that.
Would this address your feedback?
diff --git a/drivers/net/mdio/mdio-regmap.c b/drivers/net/mdio/mdio-regmap.c
index 2a0e9c519fa3..416ff4e13e8f 100644
--- a/drivers/net/mdio/mdio-regmap.c
+++ b/drivers/net/mdio/mdio-regmap.c
@@ -67,8 +67,15 @@ struct mii_bus *devm_mdio_regmap_register(struct device *dev,
 	mr = mii->priv;
 	mr->regmap = config->regmap;
 	mr->valid_addr = config->valid_addr;
-	if (config->resource)
+	if (config->resource) {
+		if (config->resource->start > U32_MAX ||
+		    config->resource->end > U32_MAX) {
+			dev_err(config->parent,
+				"Resource exceeds regmap API addressing possibilities\n");
+			return ERR_PTR(-EINVAL);
+		}
 		mr->base = config->resource->start;
+	}
 
 	mii->name = DRV_NAME;
 	strscpy(mii->id, config->name, MII_BUS_ID_SIZE);
(needs to be replicated in a bunch of other places)
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help