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

Commit 6e304f59 authored by Bartosz Golaszewski's avatar Bartosz Golaszewski Committed by Greg Kroah-Hartman
Browse files

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: default avatarBartosz Golaszewski <bgolaszewski@baylibre.com>
Reviewed-by: default avatarJohan Hovold <johan@hovoldconsulting.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@google.com>
parent 5bee7608
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -148,6 +148,9 @@ static int legacy_connection_create(struct legacy_connection *lc,

static void legacy_connection_destroy(struct legacy_connection *lc)
{
	if (!lc->connection)
		return;

	lc->connection->protocol = NULL;

	gb_connection_destroy(lc->connection);