Commit 34240e87 authored by Tuomas Tynkkynen's avatar Tuomas Tynkkynen Committed by Greg Kroah-Hartman

staging: bcm2835-audio: Don't leak workqueue if open fails

[ Upstream commit 678c5b11 ]

Currently, if bcm2835_audio_open() fails partway, the allocated
workqueue is leaked. Avoid that.

While at it, propagate the return value of
bcm2835_audio_open_connection() on failure instead of returning -1.
Signed-off-by: default avatarTuomas Tynkkynen <tuomas@tuxera.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: default avatarSasha Levin <alexander.levin@microsoft.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 8e3015e8
...@@ -442,16 +442,16 @@ int bcm2835_audio_open(struct bcm2835_alsa_stream *alsa_stream) ...@@ -442,16 +442,16 @@ int bcm2835_audio_open(struct bcm2835_alsa_stream *alsa_stream)
my_workqueue_init(alsa_stream); my_workqueue_init(alsa_stream);
ret = bcm2835_audio_open_connection(alsa_stream); ret = bcm2835_audio_open_connection(alsa_stream);
if (ret) { if (ret)
ret = -1; goto free_wq;
goto exit;
}
instance = alsa_stream->instance; instance = alsa_stream->instance;
LOG_DBG(" instance (%p)\n", instance); LOG_DBG(" instance (%p)\n", instance);
if (mutex_lock_interruptible(&instance->vchi_mutex)) { if (mutex_lock_interruptible(&instance->vchi_mutex)) {
LOG_DBG("Interrupted whilst waiting for lock on (%d)\n", instance->num_connections); LOG_DBG("Interrupted whilst waiting for lock on (%d)\n", instance->num_connections);
return -EINTR; ret = -EINTR;
goto free_wq;
} }
vchi_service_use(instance->vchi_handle[0]); vchi_service_use(instance->vchi_handle[0]);
...@@ -474,7 +474,11 @@ int bcm2835_audio_open(struct bcm2835_alsa_stream *alsa_stream) ...@@ -474,7 +474,11 @@ int bcm2835_audio_open(struct bcm2835_alsa_stream *alsa_stream)
unlock: unlock:
vchi_service_release(instance->vchi_handle[0]); vchi_service_release(instance->vchi_handle[0]);
mutex_unlock(&instance->vchi_mutex); mutex_unlock(&instance->vchi_mutex);
exit:
free_wq:
if (ret)
destroy_workqueue(alsa_stream->my_wq);
return ret; return ret;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment