From: Bartosz Golaszewski Date: Wed, 27 Jan 2016 12:17:52 +0000 (+0100) Subject: greybus: legacy: fix a null pointer dereference X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=6e304f5963ce2136cf8fda2acfb87cfe942d2e71;p=GitHub%2FLineageOS%2Fandroid_kernel_motorola_exynos9610.git 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 Reviewed-by: Johan Hovold Signed-off-by: Greg Kroah-Hartman --- diff --git a/drivers/staging/greybus/legacy.c b/drivers/staging/greybus/legacy.c index 4a45a943470d..838c70fe74c0 100644 --- a/drivers/staging/greybus/legacy.c +++ b/drivers/staging/greybus/legacy.c @@ -148,6 +148,9 @@ err_protocol_put: static void legacy_connection_destroy(struct legacy_connection *lc) { + if (!lc->connection) + return; + lc->connection->protocol = NULL; gb_connection_destroy(lc->connection);