greybus: legacy: fix a null pointer dereference

When gb_protocol_get() fails in legacy_connection_create(), we end up
bailing-out before assigning lc->connection and lc->protocol. Calling
legacy_connection_destroy() in that case results in a null pointer
dereference.

Check if lc->connection is not null before freeing it.

Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Reviewed-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
1 file changed
tree: 6846de66a191cbce0eb50c6766bf8c11ff77b1ca
  1. drivers/