lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <87jyxtaljn.fsf@miraculix.mork.no>
Date: Wed, 07 Jan 2026 09:12:28 +0100
From: Bjørn Mork <bjorn@...k.no>
To: Vladimir Oltean <vladimir.oltean@....com>
Cc: netdev@...r.kernel.org, devicetree@...r.kernel.org,
        linux-phy@...ts.infradead.org, linux-kernel@...r.kernel.org,
        linux-arm-kernel@...ts.infradead.org,
        linux-mediatek@...ts.infradead.org,
        Daniel Golle <daniel@...rotopia.org>,
        Horatiu Vultur <horatiu.vultur@...rochip.com>,
        Andrew Lunn <andrew@...n.ch>, Heiner Kallweit <hkallweit1@...il.com>,
        Russell King <linux@...linux.org.uk>,
        "David S. Miller" <davem@...emloft.net>,
        Eric Dumazet <edumazet@...gle.com>, Jakub Kicinski <kuba@...nel.org>,
        Paolo Abeni <pabeni@...hat.com>, Rob Herring <robh@...nel.org>,
        Krzysztof Kozlowski <krzk+dt@...nel.org>,
        Conor Dooley <conor+dt@...nel.org>, Vinod Koul <vkoul@...nel.org>,
        Neil Armstrong <neil.armstrong@...aro.org>,
        Matthias Brugger <matthias.bgg@...il.com>,
        AngeloGioacchino Del Regno <angelogioacchino.delregno@...labora.com>,
        Eric Woudstra <ericwouds@...il.com>,
        Marek Behún <kabel@...nel.org>,
        Lee Jones <lee@...nel.org>,
        Patrice Chotard <patrice.chotard@...s.st.com>
Subject: Re: [PATCH v2 net-next 05/10] phy: add phy_get_rx_polarity() and
 phy_get_tx_polarity()

Vladimir Oltean <vladimir.oltean@....com> writes:

> +static int fwnode_get_u32_prop_for_name(struct fwnode_handle *fwnode,
> +					const char *name,
> +					const char *props_title,
> +					const char *names_title,
> +					unsigned int default_val,
> +					unsigned int *val)
> +{
> +	int err, n_props, n_names, idx = -1;
> +	u32 *props;
> +
> +	if (!name) {
> +		pr_err("Lookup key inside \"%s\" is mandatory\n", names_title);
> +		return -EINVAL;
> +	}
> +
> +	if (!fwnode) {
> +		*val = default_val;
> +		return 0;
> +	}
> +
> +	err = fwnode_property_count_u32(fwnode, props_title);
> +	if (err < 0)
> +		return err;
> +	if (err == 0) {
> +		*val = default_val;
> +		return 0;
> +	}
> +	n_props = err;

I tried using this in the air_en8811h driver and started wondering if I
have misunderstood something.

The problem I have is that fwnode_property_count_u32() returns -EINVAL
if props_title is missing.  So if you have a node with the legacy
"airoha,pnswap-rx" property instead of "rx-polarity", or more common: no
polariy property at all, then we see -EINVAL returned from
phy_get_rx_polarity().  Which is propagated back to config_init() and
the phy fails to attach.  That can't be the intention?

The behaviour I expected is described by this test:


/* Test: tx-polarity property is missing */
static void phy_test_tx_polarity_is_missing(struct kunit *test)
{
	static const struct property_entry entries[] = {
		{}
	};
	struct fwnode_handle *node;
	unsigned int val;
	int ret;

	node = fwnode_create_software_node(entries, NULL);
	KUNIT_ASSERT_NOT_ERR_OR_NULL(test, node);

	ret = phy_get_manual_tx_polarity(node, "sgmi", &val);
	KUNIT_EXPECT_EQ(test, ret, 0);
	KUNIT_EXPECT_EQ(test, val, PHY_POL_NORMAL);

	fwnode_remove_software_node(node);
}



Bjørn

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ