From patchwork Mon Dec 8 08:17:57 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Munsie X-Patchwork-Id: 418638 X-Patchwork-Delegate: michael@ellerman.id.au Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 1E3A31400E7 for ; Mon, 8 Dec 2014 19:23:11 +1100 (AEDT) Received: from ozlabs.org (ozlabs.org [103.22.144.67]) by lists.ozlabs.org (Postfix) with ESMTP id E4D291A12A0 for ; Mon, 8 Dec 2014 19:23:10 +1100 (AEDT) X-Original-To: linuxppc-dev@lists.ozlabs.org Delivered-To: linuxppc-dev@lists.ozlabs.org Received: from ozlabs.org (ozlabs.org [IPv6:2401:3900:2:1::2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id D716E1A09C8 for ; Mon, 8 Dec 2014 19:19:39 +1100 (AEDT) Received: by ozlabs.org (Postfix) id 9452F140100; Mon, 8 Dec 2014 19:19:39 +1100 (AEDT) Delivered-To: linuxppc-dev@ozlabs.org Received: from e23smtp07.au.ibm.com (e23smtp07.au.ibm.com [202.81.31.140]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 52C831400F1 for ; Mon, 8 Dec 2014 19:19:39 +1100 (AEDT) Received: from /spool/local by e23smtp07.au.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 8 Dec 2014 18:19:38 +1000 Received: from d23dlp02.au.ibm.com (202.81.31.213) by e23smtp07.au.ibm.com (202.81.31.204) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Mon, 8 Dec 2014 18:19:36 +1000 Received: from d23relay06.au.ibm.com (d23relay06.au.ibm.com [9.185.63.219]) by d23dlp02.au.ibm.com (Postfix) with ESMTP id C63A72BB0064; Mon, 8 Dec 2014 19:19:35 +1100 (EST) Received: from d23av03.au.ibm.com (d23av03.au.ibm.com [9.190.234.97]) by d23relay06.au.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id sB88JRgP18940128; Mon, 8 Dec 2014 19:19:35 +1100 Received: from d23av03.au.ibm.com (localhost [127.0.0.1]) by d23av03.au.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id sB88J2vT032083; Mon, 8 Dec 2014 19:19:03 +1100 Received: from ozlabs.au.ibm.com (ozlabs.au.ibm.com [9.192.253.14]) by d23av03.au.ibm.com (8.14.4/8.14.4/NCO v10.0 AVin) with ESMTP id sB88J2Uf031470; Mon, 8 Dec 2014 19:19:02 +1100 Received: from dukhat.ozlabs.ibm.com (haven.au.ibm.com [9.192.253.15]) (using TLSv1.2 with cipher AES128-SHA256 (128/128 bits)) (No client certificate requested) by ozlabs.au.ibm.com (Postfix) with ESMTPSA id 03A23A0300; Mon, 8 Dec 2014 19:18:38 +1100 (AEDT) From: "Ian Munsie" To: mpe Subject: [PATCH 3/7] CXL: Fix leaking interrupts if attach process fails Date: Mon, 8 Dec 2014 19:17:57 +1100 Message-Id: <1418026681-14787-3-git-send-email-imunsie@au.ibm.com> X-Mailer: git-send-email 2.1.3 In-Reply-To: <1418026681-14787-1-git-send-email-imunsie@au.ibm.com> References: <1418026681-14787-1-git-send-email-imunsie@au.ibm.com> X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 14120808-0025-0000-0000-000000AD0CB4 Cc: cbe-oss-dev , mikey , arnd , "Aneesh Kumar K.V" , greg , linux-kernel , linuxppc-dev , anton , imunsie , jk X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org Sender: "Linuxppc-dev" From: Ian Munsie In this particular error path we have already allocated the AFU interrupts, but have not yet set the status to STARTED. The detach context code will only attempt to release the interrupts if the context is in state STARTED, so in this case the interrupts would remain allocated. This patch releases the AFU interrupts immediately if the attach call fails to prevent them leaking. Signed-off-by: Ian Munsie --- drivers/misc/cxl/file.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/misc/cxl/file.c b/drivers/misc/cxl/file.c index 378b099..2e067a5 100644 --- a/drivers/misc/cxl/file.c +++ b/drivers/misc/cxl/file.c @@ -181,8 +181,10 @@ static long afu_ioctl_start_work(struct cxl_context *ctx, ctx->pid = get_pid(get_task_pid(current, PIDTYPE_PID)); if ((rc = cxl_attach_process(ctx, false, work.work_element_descriptor, - amr))) + amr))) { + afu_release_irqs(ctx); goto out; + } ctx->status = STARTED; rc = 0;