mirror of
https://github.com/AuxXxilium/linux_dsm_epyc7002.git
synced 2025-01-15 11:46:52 +07:00
greybus: connection: prevent oops for protocol_id sysfs file
If we don't have a protocol assigned to a connection, don't oops when trying to read the "protocol_id" sysfs file. Fixes Jira SW-968. Reported-by: Alexandre Bailon <abailon@baylibre.com> Signed-off-by: Greg Kroah-Hartman <gregkh@google.com> Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org>
This commit is contained in:
parent
155b9f175e
commit
2975617421
@ -80,7 +80,10 @@ protocol_id_show(struct device *dev, struct device_attribute *attr, char *buf)
|
|||||||
{
|
{
|
||||||
struct gb_connection *connection = to_gb_connection(dev);
|
struct gb_connection *connection = to_gb_connection(dev);
|
||||||
|
|
||||||
return sprintf(buf, "%d\n", connection->protocol->id);
|
if (connection->protocol)
|
||||||
|
return sprintf(buf, "%d\n", connection->protocol->id);
|
||||||
|
else
|
||||||
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
static DEVICE_ATTR_RO(protocol_id);
|
static DEVICE_ATTR_RO(protocol_id);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user