From 4b27be1223b048322398e04fcebef7f85c0dac0d Mon Sep 17 00:00:00 2001 From: Viresh Kumar Date: Wed, 27 Jan 2016 11:16:58 +0530 Subject: [PATCH] greybus: audio_codec: Free gccodec on dia probe failure We aren't freeing the codec, that we allocated before failing to probe the connection. Free it. Signed-off-by: Viresh Kumar Reviewed-by: Johan Hovold Signed-off-by: Greg Kroah-Hartman --- drivers/staging/greybus/audio_codec.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/drivers/staging/greybus/audio_codec.c b/drivers/staging/greybus/audio_codec.c index a7ccaaad5281..5fef49552813 100644 --- a/drivers/staging/greybus/audio_codec.c +++ b/drivers/staging/greybus/audio_codec.c @@ -789,6 +789,7 @@ static int gbaudio_dai_probe(struct gb_connection *connection) int dev_id = connection->intf->interface_id; struct gbaudio_codec_info *gbcodec = dev_get_drvdata(dev); struct gb_audio_manager_module_descriptor desc; + int ret; dev_dbg(dev, "Add DAI device:%d:%s\n", dev_id, dev_name(dev)); @@ -800,8 +801,10 @@ static int gbaudio_dai_probe(struct gb_connection *connection) /* add/update dai_list*/ dai = gbaudio_add_dai(gbcodec, connection->intf_cport_id, connection, NULL); - if (!dai) - return -ENOMEM; + if (!dai) { + ret = -ENOMEM; + goto err_free_codec; + } /* update dai_added count */ mutex_lock(&gbcodec->lock); @@ -825,6 +828,10 @@ static int gbaudio_dai_probe(struct gb_connection *connection) mutex_unlock(&gbcodec->lock); return 0; + +err_free_codec: + gbaudio_free_codec(dev, gbcodec); + return ret; } static void gbaudio_dai_remove(struct gb_connection *connection) -- 2.20.1