greybus: connection: bind protocol after the connection is operational
We may bind protocol with a connection from gb_connection_create(), if bundle's device_id is already set. That's not the case until now. But if the protocol is initialized with a call to protocol->connection_init() from this place, kernel will crash. This will happen because the connection isn't fully initialized yet, for example its operation list isn't initialized yet. And as soon as the protocol driver tries to send a request to the module from its connection_init() callback, we will add an operation to this uninitialized list. And it will crash while doing: prev->next = new; Try to bind the connection with a protocol only after the connection is ready for operations. Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org> Reviewed-by: Alex Elder <elder@linaro.org> Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
This commit is contained in:
parent
463e8736a3
commit
b758d68618
@ -196,12 +196,6 @@ struct gb_connection *gb_connection_create(struct gb_bundle *bundle,
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* XXX Will have to establish connections to get version */
|
||||
gb_connection_bind_protocol(connection);
|
||||
if (!connection->protocol)
|
||||
dev_warn(&bundle->dev,
|
||||
"protocol 0x%02hhx handler not found\n", protocol_id);
|
||||
|
||||
spin_lock_irq(&gb_connections_lock);
|
||||
list_add(&connection->hd_links, &hd->connections);
|
||||
list_add(&connection->bundle_links, &bundle->connections);
|
||||
@ -210,6 +204,12 @@ struct gb_connection *gb_connection_create(struct gb_bundle *bundle,
|
||||
atomic_set(&connection->op_cycle, 0);
|
||||
INIT_LIST_HEAD(&connection->operations);
|
||||
|
||||
/* XXX Will have to establish connections to get version */
|
||||
gb_connection_bind_protocol(connection);
|
||||
if (!connection->protocol)
|
||||
dev_warn(&bundle->dev,
|
||||
"protocol 0x%02hhx handler not found\n", protocol_id);
|
||||
|
||||
return connection;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user