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 <viresh.kumar@linaro.org>
Reviewed-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
This commit is contained in:
Viresh Kumar 2016-01-27 11:16:58 +05:30 committed by Greg Kroah-Hartman
parent 2df6396160
commit 4b27be1223
1 changed files with 9 additions and 2 deletions

View File

@ -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)