Commit 29756174 authored by Greg Kroah-Hartman's avatar Greg Kroah-Hartman

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: default avatarAlexandre Bailon <abailon@baylibre.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@google.com>
Reviewed-by: default avatarViresh Kumar <viresh.kumar@linaro.org>
parent 155b9f17
......@@ -80,7 +80,10 @@ protocol_id_show(struct device *dev, struct device_attribute *attr, char *buf)
{
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);
......
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