]> www.infradead.org Git - users/dwmw2/linux.git/commitdiff
net: pse-pd: Add power limit check
authorKory Maincent <kory.maincent@bootlin.com>
Fri, 10 Jan 2025 09:40:22 +0000 (10:40 +0100)
committerPaolo Abeni <pabeni@redhat.com>
Tue, 14 Jan 2025 12:56:32 +0000 (13:56 +0100)
Checking only the current limit is not sufficient. According to the
standard, voltage can reach up to 57V and current up to 1.92A, which
exceeds the power limit described in the standard (99.9W). Add a power
limit check to prevent this.

Acked-by: Oleksij Rempel <o.rempel@pengutronix.de>
Signed-off-by: Kory Maincent <kory.maincent@bootlin.com>
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
drivers/net/pse-pd/pse_core.c
include/linux/pse-pd/pse.h

index 9fee4dd53515afad773e071c5c2a90270a48d191..432b6c2c04f836a07bf4ccc25e56b66d111fb084 100644 (file)
@@ -877,6 +877,9 @@ int pse_ethtool_set_pw_limit(struct pse_control *psec,
        int uV, uA, ret;
        s64 tmp_64;
 
+       if (pw_limit > MAX_PI_PW)
+               return -ERANGE;
+
        ret = regulator_get_voltage(psec->ps);
        if (!ret) {
                NL_SET_ERR_MSG(extack,
index 85a08c349256644000758900735b0dd05bfcb9aa..bc5addccbf32e8b36a7e5adf7db42cbb1693f029 100644 (file)
@@ -11,6 +11,8 @@
 
 /* Maximum current in uA according to IEEE 802.3-2022 Table 145-1 */
 #define MAX_PI_CURRENT 1920000
+/* Maximum power in mW according to IEEE 802.3-2022 Table 145-16 */
+#define MAX_PI_PW 99900
 
 struct phy_device;
 struct pse_controller_dev;