From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-co1nam03on0122.outbound.protection.outlook.com ([104.47.40.122]:38374 "EHLO NAM03-CO1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1729373AbeIOGuZ (ORCPT ); Sat, 15 Sep 2018 02:50:25 -0400 From: Sasha Levin To: "stable@vger.kernel.org" , "linux-kernel@vger.kernel.org" CC: Tuomas Tynkkynen , Greg Kroah-Hartman , Sasha Levin Subject: [PATCH AUTOSEL 4.14 37/57] staging: bcm2835-audio: Don't leak workqueue if open fails Date: Sat, 15 Sep 2018 01:32:53 +0000 Message-ID: <20180915013223.179909-37-alexander.levin@microsoft.com> References: <20180915013223.179909-1-alexander.levin@microsoft.com> In-Reply-To: <20180915013223.179909-1-alexander.levin@microsoft.com> Content-Language: en-US Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org List-ID: From: Tuomas Tynkkynen [ Upstream commit 678c5b119307c40f9a17152512f9c949d0ec7292 ] 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 Signed-off-by: Greg Kroah-Hartman Signed-off-by: Sasha Levin --- .../vc04_services/bcm2835-audio/bcm2835-vchiq.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/drivers/staging/vc04_services/bcm2835-audio/bcm2835-vchiq.c b/= drivers/staging/vc04_services/bcm2835-audio/bcm2835-vchiq.c index 4be864dbd41c..9eb3b625a1b1 100644 --- a/drivers/staging/vc04_services/bcm2835-audio/bcm2835-vchiq.c +++ b/drivers/staging/vc04_services/bcm2835-audio/bcm2835-vchiq.c @@ -442,16 +442,16 @@ int bcm2835_audio_open(struct bcm2835_alsa_stream *al= sa_stream) my_workqueue_init(alsa_stream); =20 ret =3D bcm2835_audio_open_connection(alsa_stream); - if (ret) { - ret =3D -1; - goto exit; - } + if (ret) + goto free_wq; + instance =3D alsa_stream->instance; LOG_DBG(" instance (%p)\n", instance); =20 if (mutex_lock_interruptible(&instance->vchi_mutex)) { LOG_DBG("Interrupted whilst waiting for lock on (%d)\n", instance->num_c= onnections); - return -EINTR; + ret =3D -EINTR; + goto free_wq; } vchi_service_use(instance->vchi_handle[0]); =20 @@ -474,7 +474,11 @@ int bcm2835_audio_open(struct bcm2835_alsa_stream *als= a_stream) unlock: vchi_service_release(instance->vchi_handle[0]); mutex_unlock(&instance->vchi_mutex); -exit: + +free_wq: + if (ret) + destroy_workqueue(alsa_stream->my_wq); + return ret; } =20 --=20 2.17.1