Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

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

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
Loading
Loading
Loading
Loading
+4 −1
Original line number Diff line number Diff line
@@ -80,7 +80,10 @@ protocol_id_show(struct device *dev, struct device_attribute *attr, char *buf)
{
	struct gb_connection *connection = to_gb_connection(dev);

	if (connection->protocol)
		return sprintf(buf, "%d\n", connection->protocol->id);
	else
		return -EINVAL;
}
static DEVICE_ATTR_RO(protocol_id);