Skip to content

Commit 34240e8

Browse files
dezgeggregkh
authored andcommitted
staging: bcm2835-audio: Don't leak workqueue if open fails
[ Upstream commit 678c5b1 ] 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: Tuomas Tynkkynen <tuomas@tuxera.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Signed-off-by: Sasha Levin <alexander.levin@microsoft.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 8e3015e commit 34240e8

1 file changed

Lines changed: 10 additions & 6 deletions

File tree

drivers/staging/vc04_services/bcm2835-audio/bcm2835-vchiq.c

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -442,16 +442,16 @@ int bcm2835_audio_open(struct bcm2835_alsa_stream *alsa_stream)
442442
my_workqueue_init(alsa_stream);
443443

444444
ret = bcm2835_audio_open_connection(alsa_stream);
445-
if (ret) {
446-
ret = -1;
447-
goto exit;
448-
}
445+
if (ret)
446+
goto free_wq;
447+
449448
instance = alsa_stream->instance;
450449
LOG_DBG(" instance (%p)\n", instance);
451450

452451
if (mutex_lock_interruptible(&instance->vchi_mutex)) {
453452
LOG_DBG("Interrupted whilst waiting for lock on (%d)\n", instance->num_connections);
454-
return -EINTR;
453+
ret = -EINTR;
454+
goto free_wq;
455455
}
456456
vchi_service_use(instance->vchi_handle[0]);
457457

@@ -474,7 +474,11 @@ int bcm2835_audio_open(struct bcm2835_alsa_stream *alsa_stream)
474474
unlock:
475475
vchi_service_release(instance->vchi_handle[0]);
476476
mutex_unlock(&instance->vchi_mutex);
477-
exit:
477+
478+
free_wq:
479+
if (ret)
480+
destroy_workqueue(alsa_stream->my_wq);
481+
478482
return ret;
479483
}
480484

0 commit comments

Comments
 (0)