Commit 7101949f authored by Dan Carpenter's avatar Dan Carpenter Committed by Greg Kroah-Hartman

usb: typec: tcpm: usb: typec: tcpm: Fix a signedness bug in tcpm_fw_get_caps()

The "port->typec_caps.data" and "port->typec_caps.type" variables are
enums and in this context GCC will treat them as an unsigned int so they
can never be less than zero.

Fixes: ae8a2ca8 ("usb: typec: Group all TCPCI/TCPM code together")
Signed-off-by: default avatarDan Carpenter <dan.carpenter@oracle.com>
Cc: stable <stable@vger.kernel.org>
Reviewed-by: default avatarGuenter Roeck <linux@roeck-us.net>
Reviewed-by: default avatarHeikki Krogerus <heikki.krogerus@linux.intel.com>
Link: https://lore.kernel.org/r/20191001120117.GA23528@mwandaSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 2636d49b
...@@ -4409,18 +4409,20 @@ static int tcpm_fw_get_caps(struct tcpm_port *port, ...@@ -4409,18 +4409,20 @@ static int tcpm_fw_get_caps(struct tcpm_port *port,
/* USB data support is optional */ /* USB data support is optional */
ret = fwnode_property_read_string(fwnode, "data-role", &cap_str); ret = fwnode_property_read_string(fwnode, "data-role", &cap_str);
if (ret == 0) { if (ret == 0) {
port->typec_caps.data = typec_find_port_data_role(cap_str); ret = typec_find_port_data_role(cap_str);
if (port->typec_caps.data < 0) if (ret < 0)
return -EINVAL; return ret;
port->typec_caps.data = ret;
} }
ret = fwnode_property_read_string(fwnode, "power-role", &cap_str); ret = fwnode_property_read_string(fwnode, "power-role", &cap_str);
if (ret < 0) if (ret < 0)
return ret; return ret;
port->typec_caps.type = typec_find_port_power_role(cap_str); ret = typec_find_port_power_role(cap_str);
if (port->typec_caps.type < 0) if (ret < 0)
return -EINVAL; return ret;
port->typec_caps.type = ret;
port->port_type = port->typec_caps.type; port->port_type = port->typec_caps.type;
if (port->port_type == TYPEC_PORT_SNK) if (port->port_type == TYPEC_PORT_SNK)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment