summaryrefslogtreecommitdiffstats
path: root/drivers/staging/greybus/legacy.c
diff options
context:
space:
mode:
authorBartosz Golaszewski <bgolaszewski@baylibre.com>2016-01-27 13:17:52 +0100
committerGreg Kroah-Hartman <gregkh@google.com>2016-01-27 17:34:54 -0800
commit6e304f5963ce2136cf8fda2acfb87cfe942d2e71 (patch)
tree6846de66a191cbce0eb50c6766bf8c11ff77b1ca /drivers/staging/greybus/legacy.c
parent5bee760890aff6dfef8b50c5e4167e9cd003ee7b (diff)
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>
Diffstat (limited to 'drivers/staging/greybus/legacy.c')
-rw-r--r--drivers/staging/greybus/legacy.c3
1 files changed, 3 insertions, 0 deletions
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);