From patchwork Thu Oct 29 12:39:03 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frederic Barrat X-Patchwork-Id: 537825 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 32961140787 for ; Thu, 29 Oct 2015 23:54:03 +1100 (AEDT) Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 0E9D01A0C97 for ; Thu, 29 Oct 2015 23:54:03 +1100 (AEDT) X-Original-To: linuxppc-dev@lists.ozlabs.org Delivered-To: linuxppc-dev@lists.ozlabs.org Received: from e06smtp17.uk.ibm.com (e06smtp17.uk.ibm.com [195.75.94.113]) (using TLSv1 with cipher CAMELLIA256-SHA (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 9B2681A0AF0 for ; Thu, 29 Oct 2015 23:39:32 +1100 (AEDT) Received: from localhost by e06smtp17.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 29 Oct 2015 12:39:28 -0000 Received: from d06dlp02.portsmouth.uk.ibm.com (9.149.20.14) by e06smtp17.uk.ibm.com (192.168.101.147) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Thu, 29 Oct 2015 12:39:25 -0000 X-IBM-Helo: d06dlp02.portsmouth.uk.ibm.com X-IBM-MailFrom: frederic.barrat@fr.ibm.com X-IBM-RcptTo: linuxppc-dev@lists.ozlabs.org Received: from b06cxnps3075.portsmouth.uk.ibm.com (d06relay10.portsmouth.uk.ibm.com [9.149.109.195]) by d06dlp02.portsmouth.uk.ibm.com (Postfix) with ESMTP id B4A88219005F for ; Thu, 29 Oct 2015 12:39:21 +0000 (GMT) Received: from d06av11.portsmouth.uk.ibm.com (d06av11.portsmouth.uk.ibm.com [9.149.37.252]) by b06cxnps3075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id t9TCdOFi59769072 for ; Thu, 29 Oct 2015 12:39:25 GMT Received: from d06av11.portsmouth.uk.ibm.com (localhost [127.0.0.1]) by d06av11.portsmouth.uk.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id t9TCdO0v023120 for ; Thu, 29 Oct 2015 06:39:24 -0600 Received: from localhost.localdomain (borneo.lab.toulouse-stg.fr.ibm.com [9.101.4.34]) by d06av11.portsmouth.uk.ibm.com (8.14.4/8.14.4/NCO v10.0 AVin) with ESMTP id t9TCdNfE023078; Thu, 29 Oct 2015 06:39:23 -0600 From: Frederic Barrat To: linuxppc-dev@lists.ozlabs.org Subject: [PATCH] cxl: Fix reference count on struct pid when attaching Date: Thu, 29 Oct 2015 13:39:03 +0100 Message-Id: <1446122343-26068-1-git-send-email-frederic.barrat@fr.ibm.com> X-Mailer: git-send-email 1.9.1 X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 15102912-0029-0000-0000-000008E0C944 X-Mailman-Approved-At: Thu, 29 Oct 2015 23:53:09 +1100 X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: imunsie@au1.ibm.com, Frederic Barrat MIME-Version: 1.0 Errors-To: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org Sender: "Linuxppc-dev" When the cxl driver creates a context, it stores the pid of the calling task, incrementing the reference count on the struct pid. Current code mistakenly increments the reference count twice, once through get_task_pid(), once through get_pid(). The reference count is only decremented once on detach, thus the struct pid of the task attaching is never freed. The fix is to simply remove the call to get_pid(). Signed-off-by: Frederic Barrat Reviewed-by: Andrew Donnellan Acked-by: Ian Munsie --- drivers/misc/cxl/api.c | 1 - drivers/misc/cxl/file.c | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/misc/cxl/api.c b/drivers/misc/cxl/api.c index 103baf0..94b6627 100644 --- a/drivers/misc/cxl/api.c +++ b/drivers/misc/cxl/api.c @@ -176,7 +176,6 @@ int cxl_start_context(struct cxl_context *ctx, u64 wed, if (task) { ctx->pid = get_task_pid(task, PIDTYPE_PID); - get_pid(ctx->pid); kernel = false; } diff --git a/drivers/misc/cxl/file.c b/drivers/misc/cxl/file.c index 7ccd299..97003ee 100644 --- a/drivers/misc/cxl/file.c +++ b/drivers/misc/cxl/file.c @@ -199,7 +199,7 @@ static long afu_ioctl_start_work(struct cxl_context *ctx, * behalf of another process, so the AFU's mm gets bound to the process * that performs this ioctl and not the process that opened the file. */ - ctx->pid = get_pid(get_task_pid(current, PIDTYPE_PID)); + ctx->pid = get_task_pid(current, PIDTYPE_PID); trace_cxl_attach(ctx, work.work_element_descriptor, work.num_interrupts, amr);