Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp94481imm; Thu, 12 Jul 2018 14:56:36 -0700 (PDT) X-Google-Smtp-Source: AAOMgpdMWZv5fB3r12p4M5FQRe16QtfXnAlS1QBkq+g10UiJffG+Q81RhXY2jbdck8Y5wKaI1eFY X-Received: by 2002:a17:902:bf43:: with SMTP id u3-v6mr3720899pls.322.1531432596212; Thu, 12 Jul 2018 14:56:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531432596; cv=none; d=google.com; s=arc-20160816; b=C10YYqRrETgVxBdwWSN/1W7hdhUz9AJsSmseSEZbcRA1ljtSHkwczf3gigc/wzg0sG xgH/SaLuZVqt+Of8eEXqtpxETOlCczsd4E76/SZoqk3rnYLEsxe/WmU8jdmjXCjtx0mt rHzeEZrkKdDlsZwz09pGTGaqYvRcD8xeHcnGXm5M4EzAM2T/WI7lCj91P+9dgtFCsPrF m5eY9Cd0diFSTRN/kaVWPlN/SrculVClYVJ9X8k9mE906Ho45OYyxmWi3BKQjxR+LQS+ boCgW0wafQx7wjyYcX6uwTA8qt8axGHQwKlicLEbUGDDSCEM3Tr3ME+AlONoZV2d9oUk 5aRw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:arc-authentication-results; bh=gszUyqNg1/1J1NtHAguvPMwUbECopWmk8ZIbuC9x+bI=; b=P71IdFZFXGdMPoAzu7oGsif0vcZXp3hmK2hNTk9II15Bfh2wJv3krKOigjjOaqexXP 9SBdl08+HAREi84bOfdojA6cpnholk8dZIE+1vojpZV0s8OIFSl8E7V9tQTFO1haDk0i dWEkd43rIl2E97wv7gH4ECTGMs1G06aTz28OijstIafTzfF437gmxbV2oMiSTqB/j5bs 0qH8gVVkKyxHbP/t6bJlDoGd3x990LnyRK4/glA5vNz1BciG7MI3BPksOFxliCDvYwz6 P0pHA482m0czRU9w0kdZa8Bzz4l2R5FY/OsWvmcOsZuBQ0jdwPyROv6G6mI+UzEi0UyW 70bA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z20-v6si25238648pfj.337.2018.07.12.14.56.21; Thu, 12 Jul 2018 14:56:36 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727057AbeGLWGP (ORCPT + 99 others); Thu, 12 Jul 2018 18:06:15 -0400 Received: from mx2.mpynet.fi ([82.197.21.85]:39201 "EHLO mx2.mpynet.fi" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726855AbeGLWGP (ORCPT ); Thu, 12 Jul 2018 18:06:15 -0400 From: Tuomas Tynkkynen To: Greg Kroah-Hartman CC: Eric Anholt , Stefan Wahren , , , , Tuomas Tynkkynen Subject: [PATCH 2/2] staging: bcm2835-audio: Don't leak workqueue if open fails Date: Fri, 13 Jul 2018 00:54:17 +0300 Message-ID: <20180712215417.22491-2-tuomas@tuxera.com> X-Mailer: git-send-email 2.16.3 In-Reply-To: <20180712215417.22491-1-tuomas@tuxera.com> References: <20180712215417.22491-1-tuomas@tuxera.com> MIME-Version: 1.0 Content-Type: text/plain X-ClientProxiedBy: tuxera-exch.ad.tuxera.com (10.20.48.11) To tuxera-exch.ad.tuxera.com (10.20.48.11) Received-SPF: none Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- .../staging/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 85ed807bb873..779c1e993b55 100644 --- a/drivers/staging/vc04_services/bcm2835-audio/bcm2835-vchiq.c +++ b/drivers/staging/vc04_services/bcm2835-audio/bcm2835-vchiq.c @@ -416,16 +416,16 @@ int bcm2835_audio_open(struct bcm2835_alsa_stream *alsa_stream) return -ENOMEM; ret = bcm2835_audio_open_connection(alsa_stream); - if (ret) { - ret = -1; - goto exit; - } + if (ret) + goto free_wq; + instance = alsa_stream->instance; LOG_DBG(" instance (%p)\n", instance); if (mutex_lock_interruptible(&instance->vchi_mutex)) { 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]); @@ -448,7 +448,11 @@ int bcm2835_audio_open(struct bcm2835_alsa_stream *alsa_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; } -- 2.16.3