mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-05-13 14:09:38 -04:00
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>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
5bee760890
commit
6e304f5963
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user